钩子文档

lostpassword_redirect

💡 云策文档标注

概述

lostpassword_redirect 是一个 WordPress 过滤器,用于修改用户在提交忘记密码表单后重定向的 URL。它允许开发者自定义密码重置请求后的跳转目标,例如重定向到首页或其他指定页面。

关键要点

  • 过滤器名称:lostpassword_redirect
  • 用途:修改密码重置请求后的重定向 URL
  • 参数:$lostpassword_redirect(字符串,重定向目标 URL)
  • 相关过滤器:与 lostpassword_url 区分,后者用于过滤密码重置页面本身的 URL
  • 引入版本:WordPress 3.0.0

代码示例

add_filter( 'lostpassword_redirect', 'my_redirect_home' );

function my_redirect_home( $lostpassword_redirect ) {
    return home_url();
}

注意事项

  • 此过滤器仅影响密码重置请求后的重定向,不改变密码重置页面的 URL
  • 确保返回有效的 URL 字符串以避免重定向错误

📄 原文内容

Filters the URL redirected to after submitting the lostpassword/retrievepassword form.

Parameters

$lostpassword_redirectstring
The redirect destination URL.

More Information

  • The lostpassword_redirect filter is used to change the location redirected to after a user requests a password reset. This could be the location set by the “redirect_to” parameter sent to the forgot password page.
  • This filter is to redirect the user following reset of the password. To filter the location of the password reset itself, use lostpassword_url.

Source

$redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect );

Changelog

Version Description
3.0.0 Introduced.

User Contributed Notes