Website Membership - Admin Notification upon new user

Re: [zick] Website Membership - Admin Notification upon new user

By Jason - November 4, 2011

Hi,

If you go onto the signup page, under the code that sends an email to the user, you can add code to send an email to the administrator as well.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Website Membership - Admin Notification upon new user

By Mikey - November 4, 2011

Jason,
I've tried both of the methods below in bold, but it doesn't work... any suggestions on what I'm doing wrong?

// send message
$emailTemplate = "emails/user-new-signup.php";
$emailHeaders = emailTemplate_load(array(
'template' => websiteLogin_pluginDir() . "/$emailTemplate",
'subject' => '', // set in template
'from' => '', // set in template
'to' => $_REQUEST['email'],
//'to' => $_REQUEST['email'],'john.doe@domain.com',
'cc' => 'john.doe@domain.com',
'placeholders' => array(
'username' => array_key_exists('username', $_REQUEST) ? $_REQUEST['username'] : $_REQUEST['email'], // if using email as username then show that instead
'password' => $password,
'loginUrl' => "http://" . $_SERVER['HTTP_HOST'] . $GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'],
),
));
$mailErrors = sendMessage($emailHeaders);
if ($mailErrors) { die("Mail Error: $errors"); }

Re: [zick] Website Membership - Admin Notification upon new user

By Jason - November 7, 2011


---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [zick] Website Membership - Admin Notification upon new user

By nmsinc - November 7, 2011 - edited: November 7, 2011

Hi zick,

I accomplished this by duplicating the "user-new-signup.php file located in the "Membership/email" folder - find the code listed below in on or about line 10:

// Override email headers - uncomment these to override the values set by the calling program
global $SETTINGS, $FROM, $TO, $SUBJECT, $PLACEHOLDERS;
$FROM = $SETTINGS['adminEmail'];
//$TO = $SETTINGS['adminEmail']; // set by program
$SUBJECT = "{$_SERVER['HTTP_HOST']} Account Details";

Make the following edits below and rename the duplicate file "admin-new-signup.php" and place in the "Membership/email" folder

// Override email headers - uncomment these to override the values set by the calling program
global $SETTINGS, $FROM, $TO, $SUBJECT, $PLACEHOLDERS;
//$FROM = $SETTINGS['adminEmail'];
$TO = $SETTINGS['adminEmail']; // set by program
$SUBJECT = "{$_SERVER['HTTP_HOST']} Account Details";

I then add an addtional email set in the user-signup.php file as follows (this way you could control the text sent to the admin) - notice that the second email set is now going to the admin!

// send message
$emailTemplate = "emails/user-new-signup.php";
$emailHeaders = emailTemplate_load(array(
'template' => websiteLogin_pluginDir() . "/$emailTemplate",
'subject' => '', // set in template
'from' => '', // set in template
'to' => $_REQUEST['email'],
'placeholders' => array(
'username' => array_key_exists('username', $_REQUEST) ? $_REQUEST['username'] : $_REQUEST['email'], // if using email as username then show that instead
'password' => $password,
'loginUrl' => "http://" . $_SERVER['HTTP_HOST'] . $GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'],
),
));
$mailErrors = sendMessage($emailHeaders);
if ($mailErrors) { die("Mail Error: $errors"); }


// send message
$emailTemplate = "emails/admin-new-signup.php";
$emailHeaders = emailTemplate_load(array(
'template' => websiteLogin_pluginDir() . "/$emailTemplate",
'subject' => '', // set in template
'from' => $_REQUEST['email'],
'to' = $SETTINGS['adminEmail'], // set by program
'placeholders' => array(
'username' => array_key_exists('username', $_REQUEST) ? $_REQUEST['username'] : $_REQUEST['email'], // if using email as username then show that instead
'password' => $password,
'loginUrl' => "http://" . $_SERVER['HTTP_HOST'] . $GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'],
),
));
$mailErrors = sendMessage($emailHeaders);
if ($mailErrors) { die("Mail Error: $errors"); }


-------- That's It -------
nmsinc

Re: [zick] Website Membership - Admin Notification upon new user

By Jason - November 7, 2011

Hi,

Sorry my last post didn't show up. I'm not sure what happened there.

Try something like this:

// send message
$emailTemplate = "emails/user-new-signup.php";
$emailHeaders = emailTemplate_load(array(
'template' => websiteLogin_pluginDir() . "/$emailTemplate",
'subject' => '', // set in template
'from' => '', // set in template
'to' => $_REQUEST['email'],
'placeholders' => array(
'username' => array_key_exists('username', $_REQUEST) ? $_REQUEST['username'] : $_REQUEST['email'], // if using email as username then show that instead
'password' => $password,
'loginUrl' => "http://" . $_SERVER['HTTP_HOST'] . $GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'],
),
));

@$emailHeaders['headers']['CC'] = "john.doe@domain.com";
$mailErrors = sendMessage($emailHeaders);

if ($mailErrors) { die("Mail Error: $mailErrors"); }


This adds the CC to the $emailHeaders array just before sendMessage is called.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/