Last active
August 17, 2021 19:55
-
-
Save nextendweb-laszlo/14bc0c1eb9ea686df273530ed70f8ad0 to your computer and use it in GitHub Desktop.
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 | |
function redirectWhenRoleMatches($user_id, $provider) { | |
$user = get_userdata($user_id); | |
$user_roles = $user->roles; | |
if (in_array('subscriber', $user_roles, true)) { | |
add_filter($provider->getId() . '_login_redirect_url', function () { | |
return 'https://example.com/page-for-subscribers'; | |
}); | |
//Or you can also use it by specifying the id of the provider directly, like: | |
/* | |
add_filter('facebook_login_redirect_url', function () { | |
return 'https://example.com/page-for-subscribers'; | |
}); | |
*/ | |
} | |
} | |
add_action('nsl_login', 'redirectWhenRoleMatches', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment