Skip to content

Instantly share code, notes, and snippets.

@csaborio001
Created May 13, 2020 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csaborio001/4ce922991db6c70eade356d61b48d63d to your computer and use it in GitHub Desktop.
Save csaborio001/4ce922991db6c70eade356d61b48d63d to your computer and use it in GitHub Desktop.
public static function external_user_redirect( $redirect_to, $requested_redirect_to, $user ) {
// Is there a user registered to check? Otherwise simply redirect.
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
// Does this user belong to the internal group?
if ( UserManagement::is_user_internal( $user ) ) {
// This will redirect them to WP-Admin.
return $redirect_to;
} elseif ( ! empty( $requested_redirect_to ) ) {
// External User with redirect.
return $requested_redirect_to;
} else {
return home_url( 'dashboard' );
}
} else {
return $redirect_to;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment