Due to company's security set up of the emails coming from the external hosting, it's needed to send password reset emails through internal email server, for that the email content needs to be sent to a secure Web API and the following needs to happen:

  1. Hook into Wordpress password reset functionality
  2. Disable the default Wordpress wp_mail() sending the emails
  3. Call the Web API with the necessary information such as email address, reset key and user login.

What would be the best way of doing so?

1 Answer 1


You can hook retrieve_password_message (code):

 * Filters the message body of the password reset mail.
 * If the filtered message is empty, the password reset email will not be sent.
 * @param string  $message    Default mail message.
 * @param string  $key        The activation key.
 * @param string  $user_login The username for the user.
 * @param WP_User $user_data  WP_User object.

Make the web API call from your filter handler and then return an empty message so no email is sent.

As above, the activation key and user login are passed to the filter as parameters and you can get the user's email address from the WP_User object, $user_data->user_email.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.