Skip to content

Instantly share code, notes, and snippets.

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 dhirenpatel22/18852b69599aa4ea322708367e00f630 to your computer and use it in GitHub Desktop.
Save dhirenpatel22/18852b69599aa4ea322708367e00f630 to your computer and use it in GitHub Desktop.
Redirect user to different page based on user role after password reset from the backend screen
<?php
/**
* Redirect user to different page based on userrole after password reset from backend screen
* @param $user
*/
function custom_redirect_retail_page_based_on_role($user) {
$user_roles = (array) $user->roles;
if ( in_array('userrole1', $user_roles) ) {
wp_redirect( 'Custom Page Link' );
} elseif (in_array('userrole2', $user_roles) ) {
wp_redirect( 'Custom Page Link' );
} else{
wp_redirect( home_url() );
}
}
add_action('after_password_reset', 'custom_redirect_retail_page_based_on_role', 10, 1 );
??>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment