I have a plugin that sets the user group based on whether a hidden checkbox has been ticked on the sign up form.
The plugin works exactly as I want it to while I'm logged in, but as soon as I log out the form reverts to default behaviour.
I can't find anything in Google about plugins misbehaving when someone logs out. Does anyone know what's going on and how I can overcome it?
Plugin code below;
public function init() {
craft()->on('users.saveUser', function(Event $event) {
$user = $event->params['user']
if ($event->params['isNewUser']) {
$groupPreference = $user->getContent()->groupPreference;
if (in_array("trade", $groupPreference)) {
craft()->userGroups->assignUserToGroups($user->id, 3);
}
}
});
}
trade
group? But when you're logged in and you save a user, it happens?