Guest User

Untitled

a guest
Dec 11th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. function redirect_logged_in_user()
  2. {
  3. if( is_user_logged_in ) {
  4. wp_redirect('http://customurl');
  5. }
  6. }
  7.  
  8. global $pagenow;
  9. if( $pagenow == 'wp-login.php')
  10. redirect_logged_in_user();
  11.  
  12. <?php
  13. function daro_login_redirect( $redirect_to, $request, $user ) {
  14. //is there a user to check?
  15. if ( isset( $user->roles ) && is_array( $user->roles ) ) {
  16. //check for admins
  17. // edit this part accordingly to your login needs:
  18. // maybe you can skip the else statement
  19. if ( in_array( 'administrator', $user->roles ) ) {
  20. // redirect them to the default place
  21. return $redirect_to;
  22. } else {
  23. return home_url();
  24. }
  25. } else {
  26. return $redirect_to;
  27. }
  28. }
  29.  
  30. add_filter( 'login_redirect', 'daro_login_redirect', 10, 3 );
Add Comment
Please, Sign In to add comment