If I want to override wp_password_change_notification, do I have to write a plugin to do this? It seems to have no effect in functions.php of my theme.
The only thing I need to do is change the wording to lower case.
if ( !function_exists('wp_password_change_notification') ) :
/**
* Notify the blog admin of a user changing password, normally via email.
*
* @since 2.7
*
* @param object $user User Object
*/
function wp_password_change_notification(&$user) {
// send a copy of password change notification to the admin
// but check to see if it's the admin whose password we're changing, and skip this
if ( $user->user_email != get_option('admin_email') ) {
$message = sprintf(__('Password lost and changed for user: %s'), $user->user_login) . "rn";
// 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);
wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message);
}
}
endif;
Yes you need to use a plugin. Point is that pluggables are between hard and impossible to control. You can read through this thread on wp-hackers about the actual problems and why you shouldn’t use them.
Important:
This means that you need the “MU-plugins” (Must use) hook:
mu_plugins_loaded
and their folder.My recommendation:
Don’t do it. Not worth the effort and problems coming with it just to get the text of an email lowercase. It’s much easier to directly hook into the
wp_mail()
filters and actions: