钩子文档

register_post

💡 云策文档标注

概述

register_post 是一个 WordPress 动作钩子,在提交用户注册表单数据后、创建用户前触发,主要用于处理注册数据。

关键要点

  • 触发时机:在提交注册表单数据后,用户创建前,早于 registration_errors 过滤器调用或错误返回。
  • 参数:$sanitized_user_login(已清理的用户名)、$user_email(提交的邮箱)、$errors(WP_Error 对象,包含用户名和邮箱的错误信息)。
  • 用途:可用于处理注册数据,但不应用于自定义验证;自定义验证应使用 registration_errors 过滤器。
  • 相关函数:register_new_user() 用于处理新用户注册。
  • 版本历史:自 WordPress 2.1.0 引入。

注意事项

此钩子不应用于自定义验证,以避免与 registration_errors 过滤器冲突。


📄 原文内容

Fires when submitting registration form data, before the user is created.

Parameters

$sanitized_user_loginstring
The submitted username after being sanitized.
$user_emailstring
The submitted email.
$errorsWP_Error
Contains any errors with submitted username and email, e.g., an empty field, an invalid username or email, or an existing username or email.

More Information

This action hook can be used to handle post data from a user registration before the registration_errors filter is called or errors are returned.

Please note that this hook should never be used for custom validation. Any custom validation rules should be performed using the registration_errors filter.

Source

do_action( 'register_post', $sanitized_user_login, $user_email, $errors );

Changelog

Version Description
2.1.0 Introduced.