Redirect Users after Login – WordPress

21 October 2011 by Rick ~ 0 Comments 1566 views

Paste this code in your functions.php and every time any non-administrator logs in he will be redirected to the home page.

add_filter("login_redirect", "subscriber_login_redirect", 10, 3);

function subscriber_login_redirect($redirect_to, $request, $user){

  if(is_array($user->roles)){

    if(in_array('administrator', $user->roles)) return home_url('/wp-admin/');

  }

  return home_url();

}

Subscribe by E-mail:

« »
Add a Comment

Use [code] example piece of code [/code] to insert code into your comment.