WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/wp login

Description

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 is an action which means that it primarily acts as an event trigger, instead of a content filter. This is a semantic difference, but it will help you to remember what this hook does if you use it like this:

<?php
function your_function() {
    // your code
}
add_action('wp_login', 'your_function');
?>

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

See Plugin API - Actions for more detail.

Source File

wp_login action hook is located in wp-includes/user.php

See also

Resources

This page is marked as incomplete. You can help Codex by expanding it.