Created
July 2, 2018 17:16
-
-
Save rosswintle/6d1cf9809282e3d232ed070b046f2d5f to your computer and use it in GitHub Desktop.
WordPress filters to make HTML password reset emails work
This file contains 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 | |
// adding support for html emails | |
// this converts ALL wp_mail emails to HTML, which messes up the password reset email | |
add_filter( 'wp_mail_content_type','prefix_set_content_type' ); | |
function prefix_set_content_type() { | |
return "text/html"; | |
} | |
// add this filter too | |
// this will make the password reset email compatible with the HTML format | |
add_filter( 'retrieve_password_message', 'prefix_retrieve_password_message', 10, 2 ); | |
function prefix_retrieve_password_message( $message ) { | |
// Revise the message content to make it HTML email compatible | |
$message = str_replace('<','',$message); | |
$message = str_replace('>','',$message); | |
$message = str_replace("\n",'<br>',$message); | |
return $message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment