在登录 wordpress 之前调用自定义函数

Call custom function before login in wordpress

我想在使用输入的登录名和密码登录之前调用自定义函数,如果该函数 returns true 用户应该继续登录。

我已经尝试 add_action('wp_login', 'do_anything'); 这样做,但它在登录后调用了我的自定义函数。

有没有办法在登录前调用自定义函数?

您正在寻找 wp_authenticate 动作挂钩。

This action is located inside of wp_signon. In contrast to the wp_login action, it is executed before the WordPress authentication process.

编辑:您的 post 中没有包含太多信息,但 wp_authenticate_user 过滤器也可能有用。

The wp_authenticate_user filter hook is used to perform additional validation/authentication any time a user logs in to WordPress.