SpinSpire logo

hiding user "history" and "member for" information from prying eyes

In Drupal, sometimes, you want to share user profiles with the world, but then they can also see the "History" and the "Member for" information about your users. If that information is not what you want to show the world, then all you have to do is implement hook_preprocess_user_profile and apply appropriate permissions to it.

function mymoduleorthemename_preprocess_user_profile(&$vars) {
  $vars['user_profile']['summary']['#access'] = user_access('administer users');
}

In the above, function name, just replace "mymoduleorthemename" with the machine-name of the module or theme you are writing the above code in. That's it!

Also, you may want a different permission from 'administer users' above. You choose what is appropriate for you.


tags: drupal