用户登录后是否有运行的挂钩?


28

我正在编写一个插件,该插件可从远程服务中获取一些扩展的用户信息,并且每次用户登录时都需要它来执行其功能。

登录后是否会触发钩子,我可以向其添加操作?

Answers:


33

动作挂钩wp_login在用户登录时运行-它可以运行一个简单的函数。

function do_anything() {
    //do stuff
}
add_action('wp_login', 'do_anything');

文档:https : //codex.wordpress.org/Plugin_API/Action_Reference/wp_login

这里真正的养家糊口的人wp_authenticate有一些文档。它使用给定的用户名和密码传递一个数组,如果需要的话,它使您有机会将信息传递给远程服务。 https://codex.wordpress.org/Plugin_API/Action_Reference/wp_authenticate

并在登录后更改重定向URL,请使用以下过滤器login_redirecthttps : //codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.