Because it’s not working for me. This code checks if a user has just registered. I want to redirect him to a custom page if so. Otherwise, redirect him to the homepage or admin page.
function mylogin_redirect($redirect_to, $url_redirect_to = '', $user = null) {
if( $user->ID ) {
$user_info = get_userdata( $user->ID );
// If user_registered date/time is less than 48hrs from now
// Message will show for 48hrs after registration
if ( strtotime( $user_info->user_registered ) > ( time() - 172800 ) ) {
return get_bloginfo('url') . "/custompage/";
} elseif( current_user_can( 'manage_options' )) {
return admin_url();
} else {
return get_bloginfo('url');
}
}
}
add_filter('login_redirect', 'mylogin_redirect');
I get the expected results for the two options but the admin. elseif( current_user_can( 'manage_options' )) { return admin_url(); }
doesn’t seem to get parsed.