Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function brg_login_redirect( $redirect_to, $request, $user ) {
- global $user;
- //if there's a user with defined roles
- if ( isset( $user->roles ) && is_array( $user->roles ) ) {
- //check if it's admin
- if ( in_array( 'administrator', $user->roles ) ) {
- //admins can go anywhere
- return $redirect_to;
- } else {
- //non-admins go to home
- return home_url();
- }
- //there's no user roles to check
- } else {
- //go home
- return home_url();
- }
- }
- add_filter( 'login_redirect', 'brg_login_redirect', 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement