Filter hook 'login_redirect'

in WP Core File wp-login.php at line 1360

View Source

login_redirect

Filter Hook
Description
Filters the login redirect URL.

Hook Information

File Location wp-login.php View on GitHub
Hook Type Filter
Line Number 1360

Hook Parameters

Type Name Description
string $redirect_to The redirect destination URL.
string $requested_redirect_to The requested redirect destination URL passed as a parameter.
WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise.

Usage Examples

Basic Usage
<?php
// Hook into login_redirect
add_filter('login_redirect', 'my_custom_filter', 10, 3);

function my_custom_filter($redirect_to, $requested_redirect_to, $user) {
    // Your custom filtering logic here
    return $redirect_to;
}

Source Code Context

wp-login.php:1360 - How this hook is used in WordPress core
<?php
1355  		 *
1356  		 * @param string           $redirect_to           The redirect destination URL.
1357  		 * @param string           $requested_redirect_to The requested redirect destination URL passed as a parameter.
1358  		 * @param WP_User|WP_Error $user                  WP_User object if login was successful, WP_Error object otherwise.
1359  		 */
1360  		$redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user );
1361  
1362  		if ( ! is_wp_error( $user ) && ! $reauth ) {
1363  			if ( $interim_login ) {
1364  				$message       = '<p class="message">' . __( 'You have logged in successfully.' ) . '</p>';
1365  				$interim_login = 'success';

PHP Documentation

<?php
/**
		 * Filters the login redirect URL.
		 *
		 * @since 3.0.0
		 *
		 * @param string           $redirect_to           The redirect destination URL.
		 * @param string           $requested_redirect_to The requested redirect destination URL passed as a parameter.
		 * @param WP_User|WP_Error $user                  WP_User object if login was successful, WP_Error object otherwise.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-login.php
Related Hooks

Related hooks will be displayed here in future updates.