I'm having problems getting onUserAfterSaveGroup to fire on Joomla3.4.x

I've published a system plugin and tested that it works using function onUserLogin(), but when I try to use function onUserAfterSaveGroup() I fail to trigger the event.

To test the plugin, I logged into the frontend as the testuser and I logged into the backend as Admin and went to Users>Usermanager>testuser>Assigned User Groups. I then added testuser to a new usergroup and clicked Save.

In the plugin I had the following code (UPDATED)

    defined('_JEXEC') or die;
    class plgSystemcustomcheckJoomlaEvents extends JPlugin {

     * Constructor.
     * @param   $subject
     * @param   array $config

    public function onUserAfterSaveGroup()
        echo "onUserAfterSaveGroup triggered";

    public function onUserLogin($user,$options)
        /*THis WORkS */
        //echo 'onUserLogin triggered'; 

I expected to see the message "onUserAfterSaveGroup" show for testuser, but this didn't happen. I tried refreshing the page, but that didn't do anything either. The event wasn't triggered for Admin either (although I wasn't expecting it to). Can someone explain why the event is not triggered for testuser?

This is a follow up to my question posted at What Joomla events are triggered when a usergroup is changed?

1 Answer 1


Maybe I wasn't clear enough on your previous question. onUserAfterSaveGroup get's triggered only if you change usergroup (not user). This is view administrator/index.php?option=com_users&view=groups.

  • Thank Rene, I think I finally get it now- onUserAfterSaveGroup fires when creating a group. It doesn't fire when assigning a group to a user. Please correct me if I'm wrong!
    – TryHarder
    Commented Dec 31, 2015 at 11:33
  • 1
    Yes, you are absolutely correct. You have to compare previous groups with new ones on event onUserBeforeSave, to see what was deleted / added. array_diff should help.
    – Rene Korss
    Commented Dec 31, 2015 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.