Created
July 19, 2020 13:16
-
-
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
This file contains hidden or 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 | |
/** | |
* 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