I'm trying to redirect certain users to a part of my site but I cannot seem to make it work... can you take a look at this and tell me what I'm doing wrong?
if ( ! function_exists( 'redirect_after_login' ) ) :
function redirect_after_login() {
global $user_ID;
if ( $user_ID === 4 ) {
global $redirect_to;
if (!isset($_GET['redirect_to'])) {
$redirect_to = get_option('siteurl') . '/stock-de-sexitive/';
}
}
}
endif;
add_action('auth_redirect', 'redirect_after_login');
Also, I know globals are dangerous, so if you know of a canonical approach that would be great too