How do I exclude a user by username or email?

  • steven
    # 7 months, 1 week ago

    I was hoping something like this would work. I would like to be able to exclude certain user from authenticating via the configured oAuth path and just authenticate against the default WordPress system. Any way to do that?

    Here’s some code I was hoping would work but no bueno…

    function exclude_users_from_oauth_authentication($user_authenticated, $user_info) {
    // Define an array of usernames to exclude
    $excluded_usernames = array(‘user1’, ‘user2’, ‘user3’);

    // Get the username of the user being authenticated
    $username = $user_info->user_login;

    // Check if the user’s username is in the excluded list
    if (in_array($username, $excluded_usernames)) {
    // User is excluded from OAuth authentication
    return true;

    // Allow authentication for all other users
    return $user_authenticated;

    // Hook into the miniOrange OAuth authentication process
    add_filter(‘mo_oauth_check_user’, ‘exclude_users_from_oauth_authentication’, 10, 2);

    # 7 months, 1 week ago

    Hi There,

    Thank you for getting in touch with us. I understand that you’re looking to implement restrictions for specific users on your WordPress site so that these users cannot perform SSO instead they can use the WordPress login form to log into the website.

    Our OAuth Client plugin allows you to restrict SSO access based on attributes returned by the identity provider. Please let us know which attributes you would like to use to restrict SSO access. You can find a comprehensive overview of all premium features here: [LINK]

    Feel free to reach out to us at for further discussions.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.