I have some profile fields created with the Profile2 module, which creates a main profile containing all the fields.
In the user/%/edit/main path, I see a new tab which displays a form to edit profile fields.

I have also three user roles, ( e.g. role A, B and C), and I want to remove that menu path for the role C. Alternatively, I want to restrict the access to those profile fields by user role.

Can I use the module Profile2 Privacy to achieve the goal?

2 Answers 2


I've done with hook_process_page() and removed the variable secondary_local_tasks before rendering to the template if the logged-in user is role C. No need additional module.

function mymodule_process_page(&$vars, $hooks){
    global $user;
    if(array_key_exists(6, $user->roles) && arg(0) == 'user' && arg(2) == 'edit'){
        # if user role C, hide profile tab
        $vars['tabs']['#secondary'] = array();
            $vars['secondary_local_tasks'] = array();

I have also tried this from hook_preprocess_page(), but it did not work on the sky theme.
Related question is here : Menu local tasks and hook preprocess


To restrict access to the fileds, I used the module Field permissions to set each field individually for each user role.

  • I have 5 profile fields in the main profile which is tab-grouped in user edit page. After I restricted access to those 5 fields, will the whole tab be thrown away from the user edit page ?
    – Sithu
    Commented Jan 30, 2012 at 7:47
  • Yes, as far as i know is the tab gone then ... but not 100% sure. Just try it out.
    – Lance
    Commented Jan 30, 2012 at 7:53
  • Unfortunately, the tab was not gone although all fields were disappeared. The form was alone with a save button. I tried to hide the secondary menu local task from hook_preprocess_menu_local_tasks(). It works on seven theme, but not in sky theme.
    – Sithu
    Commented Jan 31, 2012 at 2:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.