I am using business logic plugin to tap into save user event and create some profile field values.

public function init(){

    craft()->on('users.saveUser', function(Event $event) {


On save user returns a success object. I want to return more user profile data to the page on success.

In the save User function I have tried:

 if (craft()->request->isAjaxRequest())
     $return = array(
         'success' => true,
         'errorCode' => 1,
         'uid' => $user->id,
         'urn' => $URN

     return json_encode($return);

but I still get the usual response of success and user id. How do i get a thank you 'page' into the process so I can feedback to the user?

  • That event you're using allows you do run code when a user is saved/updated, whether that be in the front-end or in the Control Panel. Are you updating the user on the front-end?
    – Brad
    Commented Apr 25, 2017 at 20:09
  • Its incomplete. Its front end registration and code contains: if (craft()->request->isSiteRequest()) {} and if ($event->params['isNewUser']) {
    – joomkit
    Commented Apr 25, 2017 at 20:17
  • if you're doing front-end, just submit to the saveUser endpoint in the craftcms docs for registration w/ a redirect hidden input set, once it redirects to the place you set it to, you can display the user's info there, using the currentUser object, for example: currentUser.email, etc.
    – Brad
    Commented Apr 26, 2017 at 14:07
  • Its an ajax user registration.....
    – joomkit
    Commented Apr 26, 2017 at 15:08
  • One option is to hack the UsersController.php file, around line 1060 to include additional data on the return.
    – Brad
    Commented Apr 26, 2017 at 15:49

1 Answer 1


Instead of listening to the onSaveUser event, I'd update my user save form on the front-end to point to a controller's action in my plugin.

You can run similar logic to what Craft's UsersController->actionSaveUser() is doing and return any custom JSON encoded data you want back to your template.

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.