Home / Disable / Protect Elementor Forms
Duplicate Snippet

Embed Snippet on Your Site

Protect Elementor Forms

Code Preview
php
<?php
/**
 * Protect Elementor Forms
 */
add_action( 'elementor_pro/forms/validation/email', function( $field, $record, $ajax_handler ) {
	// validate email format
	if ( ! is_email( $field['value'] ) ) {
		$ajax_handler->add_error( $field['id'], 'Invalid Email address, it must be in the format [email protected]' );
		return;
	}
	$black_list_domains = [
		'fundingtree.xyz',
		'outlook.com',
		'sundatagroup.com',
		'order-fulfillment.net',
		'sundatagroup.one',
		'ywq.malsers.com',
		'bestlocaldata.com',
		'backlinkpro.club',
		'techknowspace.com',
		'lifemailnow.com',
		'fastworkingcapital.xyz',
		'talkwithweb.com',		
	];
	$email_domain = explode( '@', $field['value'] )[1];
	if ( in_array( $email_domain, $black_list_domains ) ) {
		$ajax_handler->add_error( $field['id'], 'Invalid Email address, emails from the domain ' . $email_domain . ' are not allowed.' );
		return;
	}
}, 10, 3 );

Comments

Add a Comment