Home › Forums › Quform WordPress › Creating Email Domain Filter
- This topic has 4 replies, 3 voices, and was last updated 1 year, 8 months ago by hendratok.
- AuthorPosts
- June 1, 2020 at 10:55 am #31377darksparkParticipant
Hi Ally,
I’m trying to setup a plugin filter to block specific email domains, I lifted this up from a forum topic way back. I can’t figure out how to set it up so this is going to be the default action for all forms. Will this block subdomains as well like @example.gmail.com? FYI I’m still using v1.10.
function block_free_email_addresses($valid, $value, $element) { $pattern = '/@(gmail|googlemail|hotmail|live|msn|outlook|yahoo|ymail|aol)\./i'; if (preg_match($pattern, $value)) { $element->addError('Please provide your business email.'); $valid = false; } return $valid; } add_filter('iphorm_element_valid_iphorm_1_3', 'block_free_email_addresses', 10, 3);
Thank you for looking into this, really appreciate the help.
Darkspark
- This topic was modified 4 years, 5 months ago by darkspark.
June 2, 2020 at 10:26 am #31412AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 10, 2023 at 4:45 pm #35224hendratokParticipantHi there, I tried create new version hook, but it seem don’t work?
function block_free_email_addresses($valid, $value, $element)
{
$pattern = ‘/@(.+\.)?(gmail|googlemail|hotmail|live|msn|outlook|yahoo|ymail|aol)\./i’;if (preg_match($pattern, $value)) {
$element->addError(‘Please provide your business email.’);
$valid = false;
}return $valid;
}
add_filter(‘quform_element_valid_1_11’, ‘block_free_email_addresses’, 10, 3);
`- This reply was modified 1 year, 8 months ago by hendratok. Reason: fix code mess
March 14, 2023 at 8:28 am #35228AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 14, 2023 at 1:15 pm #35237hendratokParticipantYes lol, thanks I just realize my form should be 4_11, thanks
- AuthorPosts
- You must be logged in to reply to this topic.