Last active
February 18, 2022 16:10
-
-
Save wp-user-manager/e00b8253c7719b7ef6ecd266495eb57e to your computer and use it in GitHub Desktop.
WP User Manager - Redirect users to different pages after login based on use role
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 | |
add_filter( 'wpum_redirect_after_login', function( $redirect, $user ) { | |
if ( in_array( 'author', (array) $user->roles ) ) { | |
return home_url( '/author-page' ); | |
} | |
if ( in_array( 'subscriber', (array) $user->roles ) ) { | |
return home_url( '/subscriber-page' ); | |
} | |
// Add more conditions for each role as needed | |
return $redirect; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alter the role condition and URL here and here and add other conditionals as needed.
Save this file to your /wp-content/mu-plugins/ directory (you might need to create the mu-plugins directory).