By luckyape on
I need to override the 'user/%user/edit' page for a specific user role, say 'foo_role'. I have successfully created the new user registration form that explicitly selects the fields to be used in creating a new foo_role user however, because there are additional user fields not applicable to foo_role the edit page for this role is not correct.
This is my best attempt, but it fails:
function registermodule_form_user_profile_form_alter($form, &$form_state){
global $user;
if(in_array("foo_role", $user->roles)){
unset($form['field_non_foo']);
unset($form_state['field']['field_non_foo']);
}
return $form;
}
Comments
Doh!
The problem with the function was improperly passing of the $form arg - missing &
function registermodule_form_user_profile_form_alter(&$form, &$form_state)
I was having the same issue
Eventually got it working for no visible reason. Code remained the same. Hey ho.
cache clear helps :-)
cache clear helps
:-)