Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FrancoStino/d7f264ddf9fe5b798674f487795a9a64 to your computer and use it in GitHub Desktop.
Save FrancoStino/d7f264ddf9fe5b798674f487795a9a64 to your computer and use it in GitHub Desktop.
Send a new account registration email to a personalized email
<?
/*
* Send a new account registration email to a personalized email
*/
add_action( 'user_register', 'so27450945_user_register', 10, 1 );
function so27450945_user_register( $user_id )
{
$user = get_user_by( 'id', $user_id );
$to = '[email protected]';
$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
$message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
$message .= sprintf( __( 'Username: %s'), $user->user_login ) . "\r\n\r\n";
$message .= sprintf( __( 'E-mail: %s'), $user->user_email ) . "\r\n";
@wp_mail( $to, sprintf( __( '[%s] New User Registration' ), $blogname ), $message);
}
// Function to change email address
function wpb_sender_email( $original_email_address ) {
return '[email protected]';
}
// Function to change sender name
function wpb_sender_name( $original_email_from ) {
return 'Valentino Food';
}
// Hooking up our functions to WordPress filters
add_filter( 'wp_mail_from', 'wpb_sender_email' );
add_filter( 'wp_mail_from_name', 'wpb_sender_name' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment