Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. /**
  2. * Redirect user after successful login.
  3. *
  4. * @param string $redirect_to URL to redirect to.
  5. * @param string $request URL the user is coming from.
  6. * @param object $user Logged user's data.
  7. * @return string
  8. */
  9. function qs_login_redirect( $redirect_to, $request, $user ) {
  10. //is there a user to check?
  11. if ( isset( $user->roles ) && is_array( $user->roles ) ) {
  12. //check for admins
  13. if ( in_array( 'administrator', $user->roles ) ) {
  14. // redirect them to the default place
  15. return $redirect_to;
  16. } else {
  17. return home_url('my-quiet-self');
  18. }
  19. } else {
  20. return $redirect_to;
  21. }
  22. }
  23.  
  24. add_filter( 'login_redirect', 'qs_login_redirect', 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement