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. Difference Between Filter and Action Hooks?
  2. How many times will this code run? (or, how rich is grandma?)
  3. Which hook should be used to add an action containing a redirect?
  4. add_action hook for completely new post?
  5. Add a new tab to WordPress Plugin install Listing
  6. Changing Plugin Load Order
  7. Admin settings update updating every time home page is hit?
  8. WordPress Hook for user register
  9. Global Objects and Public Methods
  10. Using filters and actions for plugin API?
  11. How should you hook a session_start() when authoring a plugin?
  12. Init action hook running late after PayPal’s return url?
  13. Is there widely accepted phpDoc syntax for documenting which hook calls a function?
  14. Explanation of the “posts_join” and “posts_fields” filter hooks?
  15. How do you use the plugin boilerplate loader class to hook actions and filters?
  16. How Do I Load My Action Earlier Enough?
  17. Does WP fire delete_post when trashed posts are automatically deleted?
  18. What’s the earliest point I can get the queried object ID?
  19. How do I Make a Theme “plugin-ready”?
  20. Why does do_action pass a blank string as the first parameter if no $arg is set?
  21. WordPress scheduled task is called but not executed
  22. Problems after wp_set_password() containing an apostrophe
  23. How to add a link to WordPress Plugin install Listing
  24. How to modify post content before writing to database?
  25. What are the default WordPress password requirements?
  26. Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
  27. How can I save a password securely as a settings field
  28. Ajax +wordpress onClick link redirect to new page and create html content
  29. How to replace settings in WordPress plugin from a theme
  30. Redirect returning users to a certain page?
  31. Restrict certain actions to plugin-specific admin menu pages only
  32. Using password protection to load different page elements?
  33. Creating posts with links from a txt file
  34. Set the payment processor callbacks to a plugin
  35. Action / Hook when a new plugin is added
  36. apply_filters() and call_user_func() to define and call a function outside a class
  37. Getting Post ID at “stylesheet” and “template” hooks
  38. How to enhance a self developed plugin by its own plugin architecture
  39. Trigger function on Remove block or add new block in Gutenberg JavaScript
  40. How to update global variables in plugin activation callback?
  41. Woocommerce get_term_by() in transition_post_status hook doesn’t works
  42. Add two button to page and post admin to redirect to : add new & list of (posts – pages) just after saving post or page
  43. `registration_errors` filter doesn’t seem to be called
  44. How to grab data after wp user search is complete
  45. Limit get_next_post to posts from the same author
  46. Any way, hook to add content right before the “read more” link?
  47. Is there any way to get post meta from publish_post hook?
  48. Why does do_action pass a blank string as the first parameter if no $arg is set?
  49. Add a custom submenu under submenu in a Custom WordPress Plugin
  50. How do I ensure I can loop through every enqueued script and CSS?
  51. Hook for validating and rejecting frontend image upload
  52. Does hooking into a plugin action / filter override the plugin’s function for that hook?
  53. Nested Hooks with do_action for performance reasons – safe/necessary?
  54. Problem in plugin debuging in wordpress
  55. WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
  56. OOP development and hooks
  57. Plugin Development – Call to undefined function comment_exists()
  58. remove different admin menu for specific users
  59. WordPress Reset password Strength set to medium
  60. Use content filter on the post that is password-protected
  61. Add_action not calling callback function
  62. replacing jquery google cdn with a new version dynamically
  63. Prevent plugin activation and add admin notice
  64. how to retrieve post_id under woocommerce_add_to_cart_validation hook?
  65. How and when would I implement some code which would take data from one part of the Db and put it in another?
  66. add_option_{$option} action hook not being called
  67. Unable to show a message after plugin activation
  68. plugin modal/popup integration best practice
  69. Function not working on any file other than the main plugin file
  70. Does WordPress have something like timer hook?
  71. Multi hook deploiement
  72. Can I use a hook other than ‘init’ to handle form submissions?
  73. Template file structure , wordpress hook for altering the template
  74. woocommerce single product page hook not working
  75. How can I set a dynamic value for post_updated_messages based on return value of post_updated?
  76. What is the use of wp_schedule_event hook?
  77. How do I replace title with my plugin?
  78. Looking for Hook that is fired after a plugin or wp upgrade is installed/updated
  79. Get user logged in status from within a plugin. $current_user not defined
  80. Woocommerce: block user removing cart item
  81. how to insert content into wp_head after loop_end
  82. Insert plugin html content to a specific spot in the frontpage
  83. Apply function on all action hooks?
  84. How can I get a plugin to hook ‘dbdelta_queries’ — a filter used during version update?
  85. Send Webhook when post-status is publish or trash
  86. Using “add_image_size” to register custom image sizes inside plugins not working
  87. get_term_by() returning null on plugin
  88. wp_head is not fired from the hook I have used in my plugin
  89. Trigger a JavaScript function based on the data fetched from Woo commerce hook
  90. Ninja Forms: Front-End Forms, Post ID?
  91. Execute callback after REST API request completes + Response is sent
  92. Custom fields in the billing address section woocommerce
  93. How to use useSelect to retrieve the currently default fontFamily?
  94. How to customize password reset message page on success if no error in password reset
  95. Is there a hook for updated image metadata upon using image editor?
  96. Can I know what changes happened after using native Image Editor?
  97. Does a wordpress custom plugin is fired by default on php theme ajax request?
  98. How to run this plugin every time a post is saved?
  99. how to execute a function only when i send an order to trash [closed]
  100. Are woocommerce_thankyou hook and is_order_received_page() redundant? [closed]
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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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