After registration hook in moodle - plugins

I want to add custom function after new user register in site. I need to create new plugin for that but i don't know about moodle hooks. What type of hook will call after user registration.

The event '\core\event\user_created' is fired when a new user account is created. You can write a plugin to handle that event.
You can declare that your plugin wants to handle that event by adding a db/events.php file within your plugin - see https://docs.moodle.org/dev/Event_2#Event_observers for more details.

Related

Dynamics CRM - Register a plug-in when the user logs in

I would like to fire an event when the user logs in to his account on Dynamics CRM ? Such as opening a Web App beside the CRM... Is This possible ?
I know that I can write plug-in that allows to augment some business process such as account creation. Any advice will be appreciated !
CRM does not expose a plugin message for "UserLogon/UserAccess" on which you can register a plugin.
What you could do though is enable Audit User Access and register your plugin on Create of an audit entity and filter on the value in AuditAction (operation) and User Access Via Web (64) is the value you are looking for.
var entity = ((Entity)pluginExecutionContext.InputParameters["Target"]).ToEntity<Audit>();
if (entity.Operation.GetValueOrDefault() == 64)
{
//logic here
}
I think dynamicallyCRM gives a good idea, but if you are trying to open some website, plugin is not the option; it's meant to execute server side logic.
If all end users use the same homepage when login to CRM (let's say they are asked not to change it), you can set up a custom page as the homepage, and there you are able to add scripts to do whatever you want.

Can I make a plugin to navigate the Web UI in Dynamics CRM

I am following the tutorial in:
https://msdn.microsoft.com/en-us/library/gg594416.aspx
to make a plugin for Dynamics CRM. It run on server side.
The plug-in creates a task activity after a new account is created. The activity reminds the user to follow-up with the new account customer one week after the account was created.
How can I extend this plugin to force the Web page to programmingly open the task that have just created?
You can't, the plugin runs server side and cannot interact with the user interface.
You would need to do something like add JavaScript that recognises when the plugin has completed and redirects the user.

Why is CRM 2013 Online Plugin running under SYSTEM user all the time

I've built a plugin for Microsoft Dynamics CRM 2013 Online platform. The plugin is registered at Delete of my_custom_entity. It is synchronous and post-operational. Impersonation is set to Calling user. As far as I know the plugin should be fired with the calling user's privileges etc. with these settings.
I can't figure out why, but my the plugin is always run under "SYSTEM" user. I've tried to use two different system users with no luck whatsoever. It's kind of a problem because my plugin is calling a workflow and the workflow is sending an email. SYSTEM user can't send emails though.
Is this something new in CRM 2013? I tried to Google but couldn't find anything relevant. I already tried to unregister and register my plugin assembly again. No difference.
How can I change my plugin registration so that it would run on behalf of a user who fires the plugin (who deletes an entity).
Thank you
How are you obtaining your service reference?
If you do it like this you should get all the actions performed as the user who triggered the plugin.
// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
If you are passing a null value you will get the system user, e.g. serviceFactory.CreateOrganizationService()
IOrganizationServiceFactory.CreateOrganizationService
Specifies the system user that calls to the service are made for. A
null value indicates the SYSTEM user. When called in a plug-in, a
Guid.Empty value indicates the same user as IPluginExecutionContext.
UserId. When called in a custom workflow activity, a Guid.Empty value
indicates the same user as IWorkflowExecutionContext.UserId. Any other
value indicates a specific system user.
YOu should use context.InitiatingUserId rather.
IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);
The InitiatingUserId will be the user who triggers the delete action. In Delete context, UserId will be System where the platform is using.

Submit One form to 2 apis

I'm trying to create a form that will submit data to 2 different API's based on a check box and one submit button.
Basically, I'm working on creating a form that allows a site vistor to register for a gotomeeting event. That's the main function of the form. Secondary to that, I want to include a check box that would allow the user to subscribe to an email list.
If the user leaves the checkbox unchecked - he or she would simply be signing up for the event via GTMeeting. If he or she checked the box, that means they register for the event and want to subscribe.
In case 2, The user data needs to be passed separately to Aweber (email client of choice here) and GoToMeeting.
I've created separate forms to handle these tasks separately - and with success. But I cannot figure out how to make the 2 post calls with just one submit button.
I read this post here from ant which seems like it should work: Submit form to 2 different action page
can anyone confirm this for me - in theory?
Thanks.
Craig

Send new user a custom messages?

I want to writ a module(plugin) for Moodle to send new users some messages.
but I don't know how to hook in signup action.
pleas help me?
the answer is that I don't need to hook to user creation.
just add a listener to user_created event
for more information see this:
Events API