Guest User

Untitled

a guest
May 20th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. add_filter('login_redirect', 'admin_login_redirect', 10, 3);
  2.  
  3. function admin_login_redirect( $redirect_to, $request, $user ) {
  4.  
  5. global $user;
  6.  
  7. if( isset( $user->roles ) && is_array( $user->roles ) ) {
  8.  
  9. if( in_array( 'administrator', $user->roles ) ) {
  10.  
  11. return $redirect_to;
  12.  
  13. } else {
  14.  
  15. return home_url();
  16.  
  17. }
  18.  
  19. } else {
  20.  
  21. return $redirect_to;
  22.  
  23. }
  24.  
  25. }
Add Comment
Please, Sign In to add comment