Last active
February 22, 2022 14:56
-
-
Save rolandinsh/5636349 to your computer and use it in GitHub Desktop.
wp_new_user_notification() - wordpress new user notification message on register
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 <[email protected]>' . "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
How to know if the function is working?