We're building a content platform for a bank for a client of us. One required feature lets relationship managers add clients (members) to the platform which get assigned a specific group.
We listen to the users.onSaveUser
event and when the specific group is chosen and the user gets added via the CP there should be sent out a specific email to that client. This is the code I have so far:
public function initRmAddsClient()
{
craft()->on('users.onSaveUser', function(Event $event) {
$user = $event->params['user'];
if ($event->params['isNewUser'])
{
//get new user group from form post
$groups = craft()->request->getPost('groups');
if ($groups)
{
if (count($groups) > 0)
{
$userGroup = craft()->userGroups->getGroupById($groups[0]);
if ($userGroup->handle == 'premium' || $userGroup->handle == 'private')
{
craft()->email->sendEmailByKey($user, 'rm_adds_client', array(
'user' => $user,
'link' => TemplateHelper::getRaw(craft()->users->getPasswordResetUrl($user)),
'rm' => craft()->userSession->getUser(),
));
}
}
}
}
});
}
I just want to add one extra check if the submission is done via the control panel since public registration is enabled as well.
Is there an easy check for that? Thanks