Skip to content

Instantly share code, notes, and snippets.

@viruthagiri
Forked from freekrai/gist:1149844
Created February 7, 2012 18:29
Show Gist options
  • Save viruthagiri/1761124 to your computer and use it in GitHub Desktop.
Save viruthagiri/1761124 to your computer and use it in GitHub Desktop.
wordpress redirect on login based on roles
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;
}
@ajaypatelaj
Copy link

not working for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment