wp_login WordPress Action Hook

The wp_login hook is triggered when a user logs in to WordPress. It can be used to perform any custom actions that need to be performed when a user logs in.

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.


Top ↑

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

Top ↑

Source

File: wp-includes/user.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
1.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More