Action hook 'auth_redirect'

in WP Core File wp-includes/pluggable.php at line 1236

View Source

auth_redirect

Action Hook
Description
Fires before the authentication redirect.

Hook Information

File Location wp-includes/pluggable.php View on GitHub
Hook Type Action
Line Number 1236

Hook Parameters

Type Name Description
int $user_id User ID.

Usage Examples

Basic Usage
<?php
// Hook into auth_redirect
add_action('auth_redirect', 'my_custom_function', 10, 1);

function my_custom_function($user_id) {
    // Your custom code here
}

Source Code Context

wp-includes/pluggable.php:1236 - How this hook is used in WordPress core
<?php
1231  			 *
1232  			 * @since 2.8.0
1233  			 *
1234  			 * @param int $user_id User ID.
1235  			 */
1236  			do_action( 'auth_redirect', $user_id );
1237  
1238  			// If the user wants ssl but the session is not ssl, redirect.
1239  			if ( ! $secure && get_user_option( 'use_ssl', $user_id ) && str_contains( $_SERVER['REQUEST_URI'], 'wp-admin' ) ) {
1240  				if ( str_starts_with( $_SERVER['REQUEST_URI'], 'http' ) ) {
1241  					wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );

PHP Documentation

<?php
/**
			 * Fires before the authentication redirect.
			 *
			 * @since 2.8.0
			 *
			 * @param int $user_id User ID.
			 */
Quick Info
  • Hook Type: Action
  • Parameters: 1
  • File: wp-includes/pluggable.php
Related Hooks

Related hooks will be displayed here in future updates.