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

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

Submitted by Jitesh Doshi on Tue, 10/07/2014 - 22:16
Drupal user history showing "member for"

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

Jitesh Doshi

Profile picture for user Jitesh Doshi
Managing Partner & CTO
  • A seasoned technology entrepreneur and enthusiast
  • A regular speaker at industry conferences and universities
  • Host and organizer of technology user groups
  • Active in management of non-profit organizations serving the local community
  • Leader and contributor for multiple open-source projects
  • Expert in cloud, application integration, web and mobile technologies
  • Author of open-source projects, including on Drupal.org - Popular Tags and PRLP.
  • Developed several highly successful software platforms and frameworks for clients