Skip to content

Instantly share code, notes, and snippets.

Last active August 17, 2021 19:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nextendweb-laszlo/14bc0c1eb9ea686df273530ed70f8ad0 to your computer and use it in GitHub Desktop.
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 '';
//Or you can also use it by specifying the id of the provider directly, like:
add_filter('facebook_login_redirect_url', function () {
return '';
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