Skip to content

Instantly share code, notes, and snippets.

@maheshruparel
Forked from rolandinsh/gist:5636349
Created July 25, 2013 06:27
Show Gist options
  • Select an option

  • Save maheshruparel/6077332 to your computer and use it in GitHub Desktop.

Select an option

Save maheshruparel/6077332 to your computer and use it in GitHub Desktop.
<?php
if ( !function_exists( 'wp_new_user_notification' ) ) {
function wp_new_user_notification( $studentID, $plaintext_pass = '' ) {
$student = new WP_User($studentID);
$student_data = get_userdata( $studentID );
$firstname = $student_data->first_name;
$student_login = stripslashes( $student_data->user_login );
// URLs
$site_url = site_url();
$ads_url = site_url( 'ads/' );
$login_url = site_url();
// Email variables
$headers = 'From: EXAMPLE.INFO <info@example.info>' . "rn";
$blog_name = get_option( 'blogname' );
$admin_subject = 'New User Registration on ' . $blog_name;
$welcome_subject = 'Welcome to EXAMPLE.INFO!';
$welcome_email = stripslashes( $student_data->user_email );
$admin_email = get_option('admin_email');
$admin_message =
<<<EOT
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>
<div class="content">
<div class="wrapper">
<p>New user registration on your blog: {$blog_name}.</p>
<p>Username: {$student_login}</p>
<p>Email: {$welcome_email}</p>
</div>
</div>
</body></html>
EOT;
$welcome_message =
<<<EOT
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>
<div class="content">
<div class="wrapper">
<table width="100%"><tr><td>
Hello {$firstname},<br />
To log into your account,
go <a href="{$login_url}">visit our site</a>
and use the credentials below.<br />
Your Username: {$student_login}<br />
Your Password: {$plaintext_pass}<br />
</td></tr></table>
</div>
</div>
</body></html>
EOT;
wp_mail( $admin_email, $admin_subject, $admin_message, $headers );
wp_mail( $welcome_email, $welcome_subject, $welcome_message, $headers );
} // End of wp_new_user_notification()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment