Welcome › mkmcst community Forum › Web programming › WordPress › Ultimate Member Code Examples › Blocking Specific Email Addresses on Registration
- This topic has 0 replies, 1 voice, and was last updated 1 year, 9 months ago by
michael mc.
Viewing 0 reply threads
-
AuthorPosts
-
-
July 9, 2023 at 3:23 PM #2633
Ultimate Member allows you to block specific email addresses from registering or signing in on your site.
Go to wp-admin> Ultimate Member> Settings > Access> Others.
To block multiple email addresses, you must use one blocked email address per line.If you encounter any issues or a security configuration warning message appears. You can try and use this code:
function um_102621_blockedemails( $args ) { $emails = UM()->options()->get( 'blocked_emails' ); if ( ! $emails ) { return; } $emails = array_map( 'rtrim', explode( "\n", $emails ) ); if ( isset( $args['user_email'] ) && is_email( $args['user_email'] ) ) { $domain = explode( '@', $args['user_email'] ); $check_domain = str_replace( $domain[0], '*', $args['user_email'] ); if ( in_array( strtolower( $args['user_email'] ), $emails ) ) { exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_email' ) ) ) ); } if ( in_array( strtolower( $check_domain ), $emails ) ) { exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_domain' ) ) ) ); } } if ( isset( $args['username'] ) && is_email( $args['username'] ) ) { $domain = explode( '@', $args['username'] ); $check_domain = str_replace( $domain[0], '*', $args['username'] ); if ( in_array( strtolower( $args['username'] ), $emails ) ) { exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_email' ) ) ) ); } if ( in_array( strtolower( $check_domain ), $emails ) ) { exit( wp_redirect( esc_url( add_query_arg( 'err', 'blocked_domain' ) ) ) ); } } } add_action( 'um_submit_form_errors_hook__blockedemails', 'um_102621_blockedemails', 10 ); remove_action( 'um_submit_form_errors_hook__blockedemails', 'um_submit_form_errors_hook__blockedemails', 10 ); Change one line from the code above as indicated below to block multiple email addresses by using a comma as a separator. $emails = array_map( 'rtrim', explode( ",", $emails ) );
-
-
AuthorPosts
Viewing 0 reply threads
- You must be logged in to reply to this topic.