How to allow specific users from a blocked domain?

If you are encountering increased malicious activity on your site, one of the best options is to block an entire service or domain (e.g., Gmail accounts) in the access tab. This option helps to prevent specific email addresses from registering or signing in on your site. However, you might still have existing clients or users that utilize addresses from the blocked domain, and you need to allow specific users from the blocked domain to register or sign in on your site. It will require customization.

To exclude specific users from the blocked domain. You can try the code snippet below:

Note: You'll need to add those specific emails in the code to exclude them from the blocked domain. You can add the code snippet to your theme's functions.php file or use the Code Snippets plugin.

In the example below, the domain '*' is blocked. So when a user tries to register on your site, they will not be able to. A message will appear that you do not accept registrations from that domain.

Add the code snippet, and make sure to add the emails you want to exclude from the blocked domain in the code.