Last active
May 11, 2020 21:45
-
-
Save wp-user-manager/85c249f5e03d68ae2f4ca651b311f412 to your computer and use it in GitHub Desktop.
WP User Manager - Redirect different users to specific pages after login
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', 'my_wpum_redirect_after_login', 10, 2 ); | |
function my_wpum_redirect_after_login( $redirect, $user ) { | |
if ( $user->ID === 1 ) { | |
$redirect = home_url( '/some-url/' ); | |
} elseif ( $user->ID === 2 ) { | |
$redirect = home_url( '/another-url/' ); | |
} | |
return $redirect; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to define the URL (or part of the URL) per user in the wp-admin, use the Custom Fields addon to create a text field with the permission set to hidden, so only admins can edit the field for users in the backend.
Use the 'Unique meta key' of the field in the code below, with the prefix 'wpum_' eg,
wpum_field_8