I want to assign a new user to a user group using a variable passed in the frontend registration form. I was going to listen for the OnSaveUser event but I don't think there's a way to get the usergroup from the original post that way(?) so I've instead created a controller that forwards to users/onSaveUser
using:
$forward = $this->forward('users/saveUser', false);
The idea being I'll then have access to the post after the user has been created. The problem is everything ends here and doesn't reach the rest of my function. Here's my controller:
<?php
namespace Craft;
class UserGroupController extends BaseController
{
protected $allowAnonymous = true;
public function actionSaveUser()
{
$this->requirePostRequest();
$forward = $this->forward('users/saveUser', false);
throw new Exception('Made It back!'); // never reached
return TRUE;
}
}
According to the Yii docs, false
should stop the things ending, right?
actionTest1()
forwarding toactionTest2()
and it works as you'd expect. UsersController->saveUser() is pretty complicated, though. My guess is that you'd going down one of the branches of it's logic where it's redirecting or ending the request via some other means. xDebugging should help see what's going on in your case.