-
-
Save viruthagiri/1761124 to your computer and use it in GitHub Desktop.
wordpress redirect on login based on roles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fs_login($user, $pass) { | |
$uname = $user; | |
$pass1 = $pass; | |
$credentials = array( | |
'user_login' => $user, | |
'user_password' => $pass, | |
'remember' => true | |
); | |
$user = wp_signon($credentials, false); | |
if( $user->ID ){ | |
update_user_meta($user->ID, '_last_loggedin', $_SERVER['REMOTE_ADDR']); | |
foreach($user->roles as $role){ | |
if($role == "Stringer" ){ | |
// redirect to stringer page | |
}else if($role == "Media" ){ | |
// redirect to media page | |
}else{ | |
// redirect to general page | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not working for me