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
Comment #1
maartenvg commentedNew features go in HEAD.
I recommend to create a patch against HEAD and post it here, that way we can review it more easily.
Comment #2
mdupontIt'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.
Comment #2.0
bnobleman commentedadded signature