Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin
Last active October 10, 2015 12:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasgriffin/3692170 to your computer and use it in GitHub Desktop.
Save thomasgriffin/3692170 to your computer and use it in GitHub Desktop.
<?php
if ( ! function_exists( 'wp_new_user_notification' ) ) :
function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
// Return early if no password is set.
if ( empty( $plaintext_pass ) ) {
return;
}
$user = get_userdata( $user_id );
$user_login = stripslashes( $user->user_login );
$user_email = stripslashes( $user->user_email );
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
// we want to reverse this for the plain text arena of emails.
$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
$message = sprintf( __( 'Username: %s' ), $user_login) . "\r\n";
$message .= sprintf( __( 'Password: %s' ), $plaintext_pass) . "\r\n";
$message .= wp_login_url() . "\r\n";
wp_mail( $user_email, sprintf( __( '[%s] Your username and password' ), $blogname ), $message );
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment