Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I just want to do something really simple.

Disable access to the user/s profile for viewing and editing. Basically users can create and account but won't be able to edit or view their own/or other users profiles.

What's the best way to do this?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Add this to a custom module:

function MYMODULE_menu_alter(&$items) {
  $items['user/%user']['access arguments'] = array('access user profiles');
  $items['user/%user']['access callback'] = 'user_access';
  $items['user/%user/edit']['access arguments'] = array('administer users');
  $items['user/%user/edit']['access callback'] = 'user_access';
}

This will put the user profile view under 'View user profiles' permission and edit under 'Administer users'.

share|improve this answer
    
thanks very much! worked a treat. I thought that I tried to do this with hook_menu but I suppose it was in the wrong place and should be in hook_menu_alter –  space_balls Aug 20 at 6:25

you can also use below method. Go to "admin/config/people/accounts/display". Set permission for individual fields don't want to show user by using https://www.drupal.org/project/field_permissions.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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