Answers.Body: <p>Instead of listening to the <code>onSaveUser</code> event, I'd update my user save form on the front-end to point to a controller's action in my plugin.</p>
  
  <p>You can run similar logic to what Craft's <code>UsersController-&gt;actionSaveUser()</code> is doing and return any custom JSON encoded data you want back to your template.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-26T18:47:46.593Z
Answers.LastActivityDate: 2017-04-26T18:47:46.593Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am using business logic plugin to tap into save user event and create some profile field values.</p>
  
  <pre><code>public function init(){
      parent::init();
  
      craft()-&gt;on('users.saveUser', function(Event $event) {
  
      }
  }
  </code></pre>
  
  <p>On save user returns a success object.
  I want to return more user profile data to the page on success.</p>
  
  <p>In the save User function I have tried:</p>
  
  <pre><code> if (craft()-&gt;request-&gt;isAjaxRequest())
   {
       $return = array(
           'success' =&gt; true,
           'errorCode' =&gt; 1,
           'uid' =&gt; $user-&gt;id,
           'urn' =&gt; $URN
       );
  
       return json_encode($return);
   }
  </code></pre>
  
  <p>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?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-25T20:09:36.180Z
Comments.Text: 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?
Comments.UserDisplayName: Brad
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-25T20:17:07.857Z
Comments.Text: Its incomplete. Its front end registration and code contains:   if (craft()->request->isSiteRequest()) {} 
  and 
     if ($event->params['isNewUser']) {
Comments.UserDisplayName: joomkit
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-26T14:07:21.010Z
Comments.Text: 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.
Comments.UserDisplayName: Brad
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-26T15:08:55.257Z
Comments.Text: Its an ajax user registration.....
Comments.UserDisplayName: joomkit
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-26T15:49:52.787Z
Comments.Text: One option is to hack the UsersController.php file, around line 1060 to include additional data on the return.
Comments.UserDisplayName: Brad
Tags: <ajax><registration>
Title: AJAX user registration and JSON returned
ThreadText: # AJAX user registration and JSON returned
  
  (Asked by: username_0 on 2017-04-25)
  
  I am using business logic plugin to tap into save user event and create some profile field values.
  
  ```
  public function init(){
      parent::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?
  
  **Tags:** ajax, registration
  
  > **Comments:**
  > **username_1**: 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?  
  > **username_0**: Its incomplete. Its front end registration and code contains:   if (craft()->request->isSiteRequest()) {}  and     if ($event->params['isNewUser']) {  
  > **username_1**: 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.  
  > **username_0**: Its an ajax user registration.....  
  > **username_1**: One option is to hack the UsersController.php file, around line 1060 to include additional data on the return.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-04-26. Score: 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.
  
  
  ---
  
  