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

Send retrieve password notification email with custom HTML email template

It was achieved using two hooks.

  1. retrieve_password_notification_email
  2. retrieve_password_message
function ashad_retrieve_password_notification_email($defaults) {
    $defaults['headers'] = array('Content-Type: text/html; charset=UTF-8');
    return $defaults;
}
add_filter('retrieve_password_notification_email', 'ashad_retrieve_password_notification_email', 10, 3);

function ashad_reset_password_message($message, $key, $user_login, $user_data )    {
    $user_fullname = $user_data->user_firstname . ' ' . $user_data->user_last_name;
    $blog_name = get_bloginfo('name');
    $reset_url = network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login');
    ob_start();
    include(get_stylesheet_directory() .  '/templates/mail/password-change.php');
    $message = ob_get_clean();
    return $message;
}
add_filter("retrieve_password_message", "ashad_reset_password_message", 99, 4);

retrieve_password_notification_email hook is used to set the header of the email as HTML and the retrieve_password_message hook is used to set the message from the password-change.php template file.

Related Posts:

  1. Which hook should be used to add an action containing a redirect?
  2. Add a new tab to WordPress Plugin install Listing
  3. Changing Plugin Load Order
  4. Admin settings update updating every time home page is hit?
  5. Global Objects and Public Methods
  6. How should you hook a session_start() when authoring a plugin?
  7. Init action hook running late after PayPal’s return url?
  8. Is there widely accepted phpDoc syntax for documenting which hook calls a function?
  9. How Do I Load My Action Earlier Enough?
  10. Does WP fire delete_post when trashed posts are automatically deleted?
  11. How do I Make a Theme “plugin-ready”?
  12. How to add a link to WordPress Plugin install Listing
  13. How to modify post content before writing to database?
  14. I can’t find where a hook is being defined in a plugin – Easy Digital Downloads
  15. How do I handle multiple Submit buttons in plugin’s option page?
  16. How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
  17. Is it possible to create an action hook using do_action() within add_action()?
  18. Hook for post permalink update
  19. Dynamically Override Fancy Title
  20. Get returned variable from a function to add_shortcode function
  21. Create a plugin to change the action to which a function is hooked
  22. Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?
  23. Adding Automatically To In WordPress Using Filter Referencing?
  24. comment_email hook doesn’t seem to work for comment editor field
  25. Best Practices for Creating and Handling Forms with Plugins?
  26. Is there a better way to implement responsive images than what WordPress uses by default?
  27. unable to stop loop when using wp_insert_post with publish_post hook
  28. Add tab to profile.php wordpress plugin development
  29. WordPress Ajax callback function from plugin – OOP
  30. How do I change the initial quantity of a product in woocommerce?
  31. Where and how does WordPress store and use its plugin and hook information?
  32. Which are the hooks run before/after when a category’s deletion?
  33. edit_{$taxonomy} | Hook
  34. WordPress after content Hook & external template part
  35. best practice for query string values – get_query_var always empty for my value supplied in query string
  36. Modifying meta tags after doing ajax call in plugin
  37. .mo translation strings not loading in PHP scripts that handle AJAX calls
  38. Where to add hooks in a class
  39. Trying to understand order and frequency of action hooks firing
  40. How to use output buffering in WordPress hooked functions?
  41. Adding option to Gallery shortcode
  42. wp_insert_user() function password never match
  43. do_action and add_action on two different installed plugins won’t work
  44. template_redirect or admin-ajax.php?
  45. I have 2 plugins using the same wp_login action hook and one is not working
  46. Add a new confirmation page before saving
  47. How dynamic action login_form_{action} is working
  48. What happens when two or more plugins use the same hook?
  49. Does admin_print_scripts-$hook_suffix work for nested paths to individual files?
  50. Bug: Post needs to be updated twice when adding action for save_post hook
  51. flush rewrite rules after plugin update?
  52. When does save_post hook fire on post save/update
  53. Plugin does not add action
  54. Add Password Generator on password protected page
  55. Add child pages to submenu automatically
  56. After plugin activation hook
  57. How to replace default comments with custom HTML?
  58. hook filter after the_content on a specific page
  59. Is there an admin hook that will let me read GET variable before it’s too late to set the header Location
  60. Why enqueue styles on hook?
  61. Call to undefined function is_home() or any conditional tags
  62. WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
  63. Run command “composer install” when activating wordpress plugin
  64. Add a check box in Menu Settings
  65. Hide one specific woocoomerce product
  66. Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
  67. Ajax +wordpress onClick link redirect to new page and create html content
  68. How to replace settings in WordPress plugin from a theme
  69. Redirect returning users to a certain page?
  70. Using password protection to load different page elements?
  71. Creating posts with links from a txt file
  72. Set the payment processor callbacks to a plugin
  73. Action / Hook when a new plugin is added
  74. apply_filters() and call_user_func() to define and call a function outside a class
  75. Getting Post ID at “stylesheet” and “template” hooks
  76. Trigger function on Remove block or add new block in Gutenberg JavaScript
  77. Woocommerce get_term_by() in transition_post_status hook doesn’t works
  78. Add two button to page and post admin to redirect to : add new & list of (posts – pages) just after saving post or page
  79. Limit get_next_post to posts from the same author
  80. Any way, hook to add content right before the “read more” link?
  81. Is there any way to get post meta from publish_post hook?
  82. Add a custom submenu under submenu in a Custom WordPress Plugin
  83. How do I ensure I can loop through every enqueued script and CSS?
  84. Plugin Development – Call to undefined function comment_exists()
  85. Use content filter on the post that is password-protected
  86. replacing jquery google cdn with a new version dynamically
  87. Prevent plugin activation and add admin notice
  88. Unable to show a message after plugin activation
  89. Does WordPress have something like timer hook?
  90. Can I use a hook other than ‘init’ to handle form submissions?
  91. Template file structure , wordpress hook for altering the template
  92. How do I replace title with my plugin?
  93. Looking for Hook that is fired after a plugin or wp upgrade is installed/updated
  94. Woocommerce: block user removing cart item
  95. how to insert content into wp_head after loop_end
  96. How can I get a plugin to hook ‘dbdelta_queries’ — a filter used during version update?
  97. Send Webhook when post-status is publish or trash
  98. Using “add_image_size” to register custom image sizes inside plugins not working
  99. wp_head is not fired from the hook I have used in my plugin
  100. Trigger a JavaScript function based on the data fetched from Woo commerce hook
Categories plugin-development Tags hooks, html-email, password, plugin-development
Redirect ignore last URL segment
check if post is set to “password protected”

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