Skip to content

Instantly share code, notes, and snippets.

@TimBHowe
Last active December 23, 2015 22:19
Show Gist options
  • Save TimBHowe/6702527 to your computer and use it in GitHub Desktop.
Save TimBHowe/6702527 to your computer and use it in GitHub Desktop.
Update the default WordPress system emails with site/blog branding.
<?php
/** custom-system-emails.php
*
* Plugin Name: Custom WordPress System Emails
* Plugin URI: http://hallme.com
* Description: This plugin custom plugin created for Process Pro to alter the default WordPress System emails. There is no admin section to this plugin so all edits will need to be made in the code.
* Version: 0.1
* Author: Hall Internet Marketing - Tim Howe
* Author URI: http://hallme.com
* Text Domain: wp-system-emails
* Domain Path: /lang
* License: GPLv2
*/
//alter the from email address on wordpress system emails
function scaffolding_filter_wp_mail_from($email){
return "noreply@DOMAIN.COM";
}
add_filter("wp_mail_from", "scaffolding_filter_wp_mail_from");
//alter the from email address on wordpress system emails
function scaffolding_filter_wp_mail_from_name($from_name){
return "BANDING FROM NAME";
}
add_filter("wp_mail_from_name", "scaffolding_filter_wp_mail_from_name");
// Redefine user notification function
if ( !function_exists('wp_new_user_notification') ) {
function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
$user = new WP_User( $user_id );
$user_login = stripslashes( $user->user_login );
$user_email = stripslashes( $user->user_email );
$message = sprintf( __('New user registration on %s:'), get_option('blogname') ) . "\r\n\r\n";
$message .= sprintf( __('Username: %s'), $user_login ) . "\r\n\r\n";
$message .= sprintf( __('E-mail: %s'), $user_email ) . "\r\n";
@wp_mail(
get_option('admin_email'),
sprintf(__('[%s] New User Registration'), get_option('blogname') ),
$message
);
if ( empty( $plaintext_pass ) )
return;
$message = __('Hi there,') . "\r\n\r\n";
$message .= sprintf( __("Welcome to %s! Here's how to log in:"), get_option('blogname')) . "\r\n\r\n";
$message .= wp_login_url() . "\r\n";
$message .= sprintf( __('Username: %s'), $user_login ) . "\r\n";
$message .= sprintf( __('Password: %s'), $plaintext_pass ) . "\r\n\r\n";
$message .= sprintf( __('If you have any problems, please contact us at %s.'), get_option('admin_email') ) . "\r\n\r\n";
$message .= __('Adios!');
wp_mail(
$user_email,
sprintf( __('[%s] Your username and password'), get_option('blogname') ),
$message
);
}
}
@TimBHowe
Copy link
Author

wp_new_user_notification needs to be defined before pluggable.php is loaded. This requires it to be in a plugin and not in a themes function file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment