W3cubDocs

/WordPress

do_action( 'wp_login', string $user_login, WP_User $user )

Fires after the user has successfully logged in.

Parameters

$user_login

(string) Username.

$user

(WP_User) WP_User object of the logged-in user.

More Information

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);
?>

Source

File: wp-includes/user.php

View on Trac

Changelog

Version Description
1.5.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/wp_login