--- user_register_notify.module1 Sun Nov 12 20:08:32 2006 +++ user_register_notify.module Mon Jan 07 14:59:12 2008 @@ -6,6 +6,40 @@ * Notifies administrator of new user registrations. */ + +/** + * Implementation of hook_menu(). + */ +function user_register_notify_menu($may_cache) { + $items = array(); + if ($may_cache) { + $items[] = array( + 'path' => 'admin/settings/register_notify', + 'title' => t('User Register Notify'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('user_register_notify_settings'), + 'description' => t('Configure the User Register Notify module.'), + 'access' => user_access('administer site configuration') + ); + } + return $items; +} + + +/** + * Menu callback for admin settings form. + */ +function user_register_notify_settings() { + $form['user_register_notify_mailto'] = array( + '#type' => 'textfield', + '#title' => t('Send notifications to this email address'), + '#description' => t('If you leave this blank, the site email address, %mailto, will be used.', array('%mailto' => variable_get('site_mail', ini_get('sendmail_from')))), + '#default_value' => variable_get('user_register_notify_mailto', ''), + ); + return system_settings_form($form); +} + + /** * Implementation of hook_user(). */ @@ -18,7 +52,12 @@ function user_register_notify_user($op, // there is already a 'pending approval' e-mail notification. if ($account->uid != 1 && $account->status) { $subject = t('Account details for !username at !site', array('!username' => $account->name, '!site' => variable_get('site_name', 'Drupal'))); - $to = $from = variable_get('site_mail', ini_get('sendmail_from')); + if (variable_get('user_register_notify_mailto', FALSE) != FALSE) { + $to = $from = variable_get('user_register_notify_mailto', 'site_mail'); + } + else { + $to = $from = variable_get('site_mail', ini_get('sendmail_from')); + } drupal_mail( 'user-register-notify-admin',