<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>

CC BY-SA 3.0
2017-04-26T18:47:46.593Z
2017-04-26T18:47:46.593Z
Brad Bell
<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>

CC BY-SA 3.0
2017-04-25T20:09:36.180Z
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
CC BY-SA 3.0
2017-04-25T20:17:07.857Z
Its incomplete. Its front end registration and code contains:   if (craft()->request->isSiteRequest()) {} 
and 
   if ($event->params['isNewUser']) {
joomkit
CC BY-SA 3.0
2017-04-26T14:07:21.010Z
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
CC BY-SA 3.0
2017-04-26T15:08:55.257Z
Its an ajax user registration.....
joomkit
CC BY-SA 3.0
2017-04-26T15:49:52.787Z
One option is to hack the UsersController.php file, around line 1060 to include additional data on the return.
Brad
<ajax><registration>
AJAX user registration and JSON returned
# 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.


---

