Posted by scb on March 9, 2007 at 3:32pm
4 followers
Jump to:
| Project: | Drupal core |
| Version: | 8.x-dev |
| Component: | contact.module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
It would be interesting if one could assign an existing user to be the recipient for a category that has been set up in the sitewide contact form. So, the admin would be able to choose email addresses as recipient, OR/AND select existing user(s) as recipients for that category.
This way, if users change their email addresses in their profiles, the contact form will still be sent to them, because their emails would be read automatically from their profiles right before sending.
Comments
#1
I have just tried to implement this behaviour, and it is working (version 5.1).
Now it also accepts usernames as recipients, in the comma-separated list. Changes made in comment.module:
1. Change help message @ line 172
<?php'#description' => t("Enter the recipients' email addresses or usernames. Example: 'webmaster@example.com', 'admin' or 'sales@example.com,admin,support@example.com'. To specify multiple recipients, separate each e-mail address with a comma."),
?>
2. Near line 215 change this code:
<?phpif (!valid_email_address(trim($recipient))) {
form_set_error('recipients', t('%recipient is an invalid e-mail address.', array('%recipient' => $recipient)));
}
?>
For this one:
<?phpif (!valid_email_address(trim($recipient))) {
if(!user_search('search',check_plain(trim($recipient)))) {
form_set_error('recipients', t('%recipient is an invalid e-mail address or username.', array('%recipient' => $recipient)));
}
}
?>
3. And near line 530, right after this:
<?php// Prepare the body:
$body = implode("\n\n", $message);
?>
add this code:
<?php//Read email for all usernames listed as recipients
$recipients_array = explode(',',$contact->recipients);
foreach($recipients_array as $k => $r){
if (!valid_email_address($r)) { //it is a username
if($u=user_load(array('name' => $r))) {
$recipients_array[$k] = $u->mail;
}
}
}
$contact->recipients = implode(',',$recipients_array);
?>
#2
Please submit a proper patch so that it can be reviewed properly. Thanks.
#3
Bumping version to 7.x for feature requests.
#4
Not likely to make it into D7 at this point. Bumping to D8.