钩子文档

user_request_action_email_subject

💡 云策文档标注

概述

user_request_action_email_subject 是一个 WordPress 过滤器钩子,用于自定义用户账户操作确认邮件的主题。它允许开发者根据站点名称和邮件数据动态调整邮件主题内容。

关键要点

  • 这是一个过滤器钩子,用于修改账户操作确认邮件的主题。
  • 接收参数包括原始主题、站点名称和包含请求对象、邮箱地址等详细数据的数组。
  • 常用于 wp_send_user_request() 函数中,以增强邮件个性化。

代码示例

$subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );

注意事项

  • 确保钩子函数返回有效的字符串作为邮件主题。
  • 参数 $email_data 包含用户请求、邮箱地址、操作描述等关键信息,可用于定制主题。
  • 此钩子自 WordPress 4.9.6 版本引入,使用时需注意版本兼容性。

📄 原文内容

Filters the subject of the email sent when an account action is attempted.

Parameters

$subjectstring
The email subject.
$sitenamestring
The name of the site.
$email_dataarray
Data relating to the account action email.

  • request WP_User_Request
    User request object.
  • email string
    The email address this is being sent to.
  • description string
    Description of the action being performed so the user knows what the email is for.
  • confirm_url string
    The link to click on to confirm the account action.
  • sitename string
    The site name sending the mail.
  • siteurl string
    The site URL sending the mail.

Source

$subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );

Changelog

Version Description
4.9.6 Introduced.