It would be useful to expose the "User: mail" field for node authors, so a View could be generated to list all usernames and email addresses, then exposed as a Views CSV output for using with an external mail campaign application or traditional mail merge operation.

From the looks of it this is a small modification to the views_user.inc file?

CommentFileSizeAuthor
#9 views-DRUPAL-5.e-mail.patch888 bytessun
#2 mw.patch913 bytesmoshe weitzman

Comments

moshe weitzman’s picture

As long as the help text has a big warning in the field help text, i think this is acceptable. default drupal does not ever disclose user email address, thus the caution.

moshe weitzman’s picture

Title: Expose users email address field » Expose node author's email address as a field
Assigned: Unassigned » moshe weitzman
Status: Active » Reviewed & tested by the community
StatusFileSize
new913 bytes

Here is a patch. this patch is running fine on boston2008 so i just set to RTBC

mlncn’s picture

This worked for us also. (I added a handler function modeled on the author name handler function, but I'm sure the reason it didn't show up at first was not clearing the views cache at admin/build/views/tools .)

Some keywords to help people find this issue:

Node author's e-mail field for Drupal views
Drupal export users with e-mail addresses
Drupal show node author email Views
view user emails
show node author email

benjamin, Agaric Design Collective

sun’s picture

Status: Reviewed & tested by the community » Needs work

'help' should use double-quotes.

Johnny vd Laar’s picture

i've used this idea for comments emailaddresses but isn't there a way to put this in a seperate module. i don't want to modify the views module for this

dwees’s picture

Possible handler for creating a link to an individual users contact form:

/*
 * Format as a field as a user email to link to a contact form. Needs to also have a 'uid' available 
 */
function views_handler_field_usermail($fieldinfo, $fielddata, $value, $data) {
  if (module_exists('contact')) {
    return l($value, "user/". $data->users_uid ."/contact");
  }
  else {
    return $value;
  }
}

and in the original table definition change


      'mail' => array(
        'name' => t('User: Email'),
        'sortable' => TRUE,
        'help' => t('Display the user\'s email address. Beware that this should only be shown to administrators in a normal Drupal installation. Further, no attempt is made to obfuscate the email address.'),
      ),

to


      'mail' => array(
        'name' => t('User: Email'),
        'handler' => 'views_handler_field_usermail',
        'uid' => 'uid',
        'addlfields' => array('uid'),
        'sortable' => TRUE,
        'help' => t('Display the user\'s email address. No attempt is made to obfuscate the email address, so these should never be made public.'),
      ),

If the contact module is enabled, the email text links to the contact form, otherwise it displays as plain text. Since emails addresses of users are already always filtered, this doesn't need to be run through check_plain()

Dave

sun’s picture

Status: Needs work » Reviewed & tested by the community
arthurf’s picture

Applies correctly and works as expected.

sun’s picture

Status: Reviewed & tested by the community » Fixed
StatusFileSize
new888 bytes

Committed with slight corrections.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.