Fires after the user has successfully logged in.
The wp_login action hook is triggered when a user logs in by the wp_signon() function. It is the very last action taken in the function, immediately following the wp_set_auth_cookie() call.
This hook provides access to two parameters: $user->user_login (string) and $user ( WP_User ). To pass them into your function you will need to add a priority (default is 10) and request 2 arguments from the add_action() call:
<?php
function your_function( $user_login, $user ) {
// your code
}
add_action('wp_login', 'your_function', 10, 2);
?> do_action( 'wp_login', $user->user_login, $user );
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/wp_login