Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wp-user-manager/e00b8253c7719b7ef6ecd266495eb57e to your computer and use it in GitHub Desktop.
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
<?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 );
@wp-user-manager
Copy link
Author

wp-user-manager commented Nov 6, 2019

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment