Created
July 4, 2014 23:15
-
-
Save gmaggio/8f74eeed29e414688b60 to your computer and use it in GitHub Desktop.
[Wordpress] Redirect Non-Admin Users to Homepage After Login ( http://tommcfarlin.com/redirect-non-admin/ )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Redirect non-admins to the homepage after logging into the site. | |
* | |
*/ | |
function my_login_redirect ( $redirect_to, $request, $user ) { | |
return ( is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) ? admin_url() : site_url(); | |
} // end my_login_redirect | |
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 ); | |
// Source: http://tommcfarlin.com/redirect-non-admin/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment