Allow users with permission 'view emails on user profiles' to view registration email address of other Drupal users.
Below tried and tested code.

/**

* Implementation of hook_user().

*

*/

function nobleprog_user($op, $edit, &$user, $category = NULL) {

if('view' == $op and user_access('view emails on user profiles')){

$fields = array();

$title = '';

$fields[$title][] = array(

'title' => 'EMAIL',

'value' => l($user->mail,"mailto:$user->mail"),

'class' => 'nodeprofile-display',

'weight' => nodeprofile_get_settings('weight', $type),

);

}

return $fields;

}

function nobleprog_perm(){

return array('view emails on user profiles') ;

}

-------
Bernard Szlachta
http://www.nobleprog.co.uk/drupal/training
http://www.nobleprog.us/drupal-training-courses

Comments

maartenvg’s picture

Version: 5.x-dev » 7.x-dev

New features go in HEAD.

I recommend to create a patch against HEAD and post it here, that way we can review it more easily.

mdupont’s picture

Status: Active » Closed (won't fix)

It's a good practice to hide email addresses by default (rather than displaying them publicly) and if someone wants to display them anyway it is very easy to do so through hook_user_view() or in a View (and add access control there).

As the current implementation seems fine for the 80% it won't be changed in Drupal core. However it can be easily provided in a contrib module.

bnobleman’s picture

Issue summary: View changes

added signature