-
- 40 Posts
I have a plugin that updates a mailing list on Campaign Monitor when a user is created/saved. It listens to the OnUserFormSave event, which works great if the user is updated from under Security > Manage users.
However, if users update their own profile (User > Profile) I can't seem to trigger the plugin. I've tried listening to both OnUserFormSave and OnUserSave, but nothing happens.
Any ideas? Should I listen to to some other event?
-
- 40 Posts
No one have any ideas here?
It doesn't appear to trigger any events, but it does allow for PostHooks.
postHooks A comma-separated list of 'hooks', or Snippets, that will be executed after the user's profile is updated.
-
- 24,544 Posts
I think you could create a postHook with this code:
/* invoke OnUserFormSave event */
/* I'm guessing at the user settings */
$user = $scriptProperties['updateprofile.user'];
$userId = $user->get('id');
$modx->invokeEvent('OnUserFormSave',array(
'mode' => modSystemEvent::MODE_UPD
'user' => $user,
'id' => $userId,
));
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
-
- 40 Posts
Hi,
I don't quite follow. BobRay, I assume your code triggers the OnUserFormSave event and passes along the correct variables? But how is this postHook triggered in the first place, i.e. how do I execute the code/snippet?
-
- 24,544 Posts
I assumed that you were using the UpdateProfile snippet. If so, you should be able to specify your snippet in the &postHooks property. If the user is updating their Profile in the Manager, OnUserFormSave should definitely be firing already. If not, it would be a bug.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
-
- 24,544 Posts
Ah, I forgot that menu existed. I looked at the code, and it saves just the profile without saving the user object or firing any events.
I would put in a feature request for an OnSaveUserProfile event or the equivalent.
If you feel daring, you could create such an event and put code to invoke it in the profile update processor.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html