Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Set content type to HTML for lost password email only

I suspect you implemented the hook something like this:

function wp_set_html_mail_content_type() {
    return 'text/html';
}
add_filter( 'wp_mail_content_type', 'wp_set_html_mail_content_type' );

More info: https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_content_type

Did you need to reset the content type at a later point?


** UPDATE: try intercept it with a global variable:

function xxx_wp_email_content_type() {
    if($GLOBALS["use_html_content_type"]){
        return 'text/html';
    }else{
        return 'text/plain';
    }
}
add_filter( 'wp_mail_content_type', 'xxx_wp_email_content_type' );

function xxx_wp_retrieve_password_message( $content, $key ) {
    ob_start();

    $GLOBALS["use_html_content_type"] = TRUE;

    $email_subject = xxx_wp_retrieve_password_title();

    include( 'templates/email_header.php' );
    include( 'templates/lost_password_email.php' );
    include( 'templates/email_footer.php' );

    $message = ob_get_contents();
    ob_end_clean();

    return $message;
}
add_filter( 'retrieve_password_message', 'xxx_wp_retrieve_password_message', 10, 2 );

Related Posts:

  1. How to change user password with wp-cli?
  2. wordpress redirect after password reset
  3. Loosen/disable password policy
  4. Password Protect Custom Page
  5. Password protecting a page
  6. How to save Admin FTP password
  7. How can I change the default wordpress password hashing system to something custom?
  8. If I change the salt keys in my wp-config will all passwords break?
  9. Conditional to test if post has password protection enabled
  10. Bypass password protected posts via GET variable
  11. Check the password of a user
  12. How to add Wp_error using lostpassword_post hook when validating custom field?
  13. Create a USERNAME and PASSWORD protected WordPress page
  14. Why do generated passwords start/end with spaces?
  15. Duplicate hash method for password in .NET
  16. Hide password protected posts
  17. Safe to store SMTP password in wp-config.php?
  18. Access code/password only restricts page access, no user registration..?
  19. PasswordHash not found in namespace
  20. Force all users in MU to change their passwords
  21. Reseting admin password through PHPMyadmin fails
  22. Check Password Reset Key Not Woking
  23. Reset password – set minimum length for new password
  24. How to shorten length of auto generated password sent during registration?
  25. Forgot password not working
  26. wp_hash_password unexpected behaviour
  27. Password reset message – change the network_home_url( ‘/’ )
  28. Redirect a password protected page?
  29. Lost password link is redirecting to /shop/my-account/lost-password/
  30. WordPress: force users to change password on first login
  31. Can’t login to wordpress despite changing password to something known directly in MySQL or using “Password Reset by Email” feature
  32. Change default recovery link expiration time
  33. Lost password link redirects to my-account/lost-password/,how to fix it back to default lost password
  34. Password protect custom template
  35. Custom password generator for users
  36. Where is the reset password key stored/generated?
  37. Password protecting template, secured content not showing if even password is right
  38. How validate usernames/passwords against WP’s database?
  39. Make post password required to publish
  40. WordPress reset password returns invalid key
  41. Add error message on password protected pages
  42. User password field is empty
  43. Password reset bug? – “Sorry, that key does not appear to be valid”
  44. How to set minimum length and error message for password recovery?
  45. Why is resetting the WordPress Users password not working?
  46. Get plain password on register
  47. post_password_required() not recognizing cookie set with correct password
  48. How Authentication in wordpress works? wp_authenticate_username_password()
  49. Password protect the site (without htaccess or membership)
  50. Password Protected page not asking for a password
  51. I would like to password protect my entire WordPress site (ip validated), except for one page
  52. Password protection for page template
  53. Custom login form for front-end user as well as admin
  54. how to remotely check a username / password from within a plugin
  55. Password changed [duplicate]
  56. Enable Update button only when password is shown strong
  57. How to get user password before being encrypted outside the wordpress core once add a new user from dashboard?
  58. Adding parameters to password reset key
  59. wp_hash_password create a different hash everytime
  60. Custom password form allows unlock two posts with the same password
  61. How to change password
  62. Generating the password reset link automatically
  63. Password protect pages – allow more than one password
  64. password recovery key is invalid on custom reset
  65. Like to store multiple passwords in db table wp_posts field post_password?
  66. Password Protected Post is invisible until you login
  67. Send password to user instead of reset password link
  68. Protect Passwords in wp_users with stronger protection than MD5
  69. Custom form for password protected page
  70. How secure is a wp-config file?
  71. How to check user’s password?
  72. How to Remove or Deactivate “Application Passwords” in WordPress
  73. What’s the algorithm to verify user password?
  74. How to change “Reset Password” text on submit button
  75. Customize retrieve password message
  76. How to recover password from a user
  77. resend user login & password with custom button
  78. WordPress admin creation through phpmyadmin not working
  79. How to show my wordpress admin username & password?
  80. Why does hashing a password result in different hashes, each time?
  81. Can’t alter $lostpassword_url
  82. current user’s password check
  83. How to initiate password reset flow by code
  84. Change password fields
  85. lostpassword_redirect filter is not used
  86. How to read third party cookie to access password protected pages
  87. Ask logged in user to re-enter password to access page “x”
  88. Password Protect or IP to access under development WordPress site otherwise shown a placeholder page
  89. Password protected sites
  90. Password-protected page redirecting to frontpage when I enter the password
  91. 2 accounts under same email preventing me from loging in
  92. How would I create a Password Protected Page with Content on it?
  93. Site only for users authenticated by different PHP application
  94. wordpress custom password change problem
  95. Allow all reset password links within the past 24 hours to be valid and accepted
  96. WooCommerce Lost Password reset goes to 404
  97. Set id and password for each post
  98. I have to reset the admin password each time
  99. I need help with wp_lostpassword, wp_register and wp_login_form
  100. Create Member who can’t be changed
Categories password Tags html-email, password
Deleting images through upload folder, but not deleting from media library
Remove image from post also removes photo from media library

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress