Skip to content

Instantly share code, notes, and snippets.

@jaygooby
Created February 25, 2013 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaygooby/5031419 to your computer and use it in GitHub Desktop.
Save jaygooby/5031419 to your computer and use it in GitHub Desktop.
34 // Redirect admins to the dashboard and other users elsewhere
35 add_filter( 'login_redirect', 'dkis_login_redirect', 10, 3 );
36 function dkis_login_redirect( $redirect_to, $request, $user ) {
37 // Is there a user?
38 if ( is_array( $user->roles ) ) {
39 // Is it an administrator?
40 if ( in_array( 'administrator', $user->roles ) ):
41 return '/wp-admin/';
42 else:
43 if ( in_array( 'teacher', $user->roles ) ):
44 return home_url( '/music-leader-zone/teacher-register-login/' );
45 else:
46 if ( in_array( 'school', $user->roles ) ):
47 return home_url( '/school-zone/school-register-login/' );
48 else:
49 return home_url();
50 endif;
51 endif;
52 endif;
53 }
54 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment