Answer the question
In order to leave comments, you need to log in
User roles vs hook_user_presave
A warning! This question will be answered immediately. It's just that the proposed text below somehow does not pull on a full-fledged article.
In general, hook_user_presave is a rather capricious thing, and if you work with the $account object, and not with the $edit array, you need to save the user profile twice in order to properly process the hook.
user_access('administer role',$edit);
user_access('administer role',$edit);
foreach($edit['roles'] as $key=>$val){
if((bool)$val){
$role = user_role_load($key);
$edit['roles'][$key] = $role->name;
}
else{
unset($edit['roles'][$key]);
}
}
unset($key,$val);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question