I would like to be able to perform actions on those users that register through the front end and skip ones who are created in the CP... is there are way of checking or a parameter accessible in the onBeforeSaveUser or onSaveUser events?

I assume there must be something hidden in there as users registered on the front end can be assigned to a certain user group which isn't applied to a CP registration.

  • Just did a bit more digging and found the variable $thisIsPublicRegistration floating around the actionSaveUser method, should have been looking in the controller not the service duoh! This is set by checking of there is a current logged in user, is this the best way to do this in the onBeforeSaveUser and onSaveUser events too?
    – Neal Hulme
    Oct 21, 2014 at 14:08
  • You should be able to check the same way in the onBeforeSaveUser but not necessarily in the onSaveUser. It may depend on the auto-login settings and when that gets fired. What are you trying to ultimately accomplish? Oct 21, 2014 at 14:24
  • Update: It looks like the impersonate($user->$id) on line 822 of UsersController executes after the onSaveUser event fires, so should be a safe check there also. Oct 21, 2014 at 14:38

1 Answer 1


You already answered your own question, but I thought I would post an example. In the plugin's class definition file create an init method with the following:

public function init()

    craft()->on('users.saveUser', function(Event $event) 
        $user = $event->params['user'];
        $isNewUser = $event->params['isNewUser'];

        if ($isNewUser && !$currentUser) {

            // do your thing, whatever it is


This should only target 'new user registrations' by users who are 'not already logged in' (i.e. public registrations through the front-end). By the time the Users Service has raised the event, it should have already passed all the other checks, regarding whether to allowPublicRegistration, etc.

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.