最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Sending Reset Password email via Web API

programmeradmin5浏览0评论

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?

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?

Share Improve this question asked Jan 21, 2020 at 19:09 VictorVictor 1112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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.

发布评论

评论列表(0)

  1. 暂无评论