Created
December 1, 2025 11:41
-
-
Save yuriinalivaiko/663bc1b8fd2d4b6059e9219f7d23021d to your computer and use it in GitHub Desktop.
Ultimate Member customization. Block registration that contains specific strings in the email domain.
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 | |
| // Custom validation for the "E-mail Address" field on registration. | |
| // Block registration that contains specific strings in the email domain. | |
| function um_validate_email_domain( $args ) { | |
| // List blocked email domains here (entire domain or a part of it). | |
| $blocked_email_domains = array( | |
| 'vovk.store' | |
| ); | |
| // Change error message here. | |
| $message = __( 'You can not use this email domain for registration', 'ultimate-member' ); | |
| if ( isset( $args['user_email'] ) && is_email( $args['user_email'] ) ) { | |
| $email_domain = array_pop( explode( '@', trim( $args['user_email'] ) ) ); | |
| foreach ( $blocked_email_domains as $blocked_email_domain ) { | |
| if ( false !== stripos( $email_domain, $blocked_email_domain ) ) { | |
| UM()->form()->add_error( 'user_email', $message ); | |
| } | |
| } | |
| } | |
| } | |
| add_action( 'um_submit_form_errors_hook__registration', 'um_validate_email_domain', 20 ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code snippet can be useful if spammers are using multiple email domains based on the same higher-level domain.
Use the "Blocked Email Addresses" setting on wp-admin > Ultimate Member > Settings > Access > Other to block an entire email domain. Read article Block Email address on Registration for details.