Creating Email Domain Filter

Home Forums Quform WordPress Creating Email Domain Filter

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #31377
    darkspark
    Participant

    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 3 years, 11 months ago by darkspark.
    #31412
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #35224
    hendratok
    Participant

    Hi 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, 1 month ago by hendratok. Reason: fix code mess
    #35228
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #35237
    hendratok
    Participant

    Yes lol, thanks I just realize my form should be 4_11, thanks

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy