This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Blocking emailadresses from email field [urgent]!


  1. MvdL79
    Member

    Yuniar,

    A "quick" question; is there a fast way to block email accounts like @hotmail.com, @msn.com, @gmail.com, @live.nl, etc. from the email field?

    Our company does not accept orders from those emailaccounts.

    Please advice... Thanks in advance!

    Posted 15 years ago #
  2. MvdL79
    Member

    Oh and if it's possible only for specific forms, so we can still use, for example, Hotmail accounts on some forms (e.g. migration forms).

    Currently we have about 14 active forms. However from form 1 through 11 it's not allowed to use free emailaccounts like Hotmail and Gmail, but on forms 12 through 14 it is allowed to use these.

    Hopefully I made myself clear! Thank you.

    Posted 15 years ago #
  3. redityo

    Hi,

    In this case you should add another validation to block those e-mails. Open your "includes/common-validator.php" and add those code on line 28.

    //validation for email address
    function validate_blacklist_mail($value){
    
    	//define blocked email address
    	$block_email_list = '@test.com,@wow.com';
    
    	$blacklisted_mail = explode(',',strtolower($block_email_list));
    
    	if(in_array(strstr($value[0],'@'),$blacklisted_mail)){
    		return 'This email not allowed';
    	} else {
    		return true;
    	}			
    
    }

    in there I assume you want to block e-mail from test.com and wow.com. After that edit your "includes/post-functions.php" and search on line 289, you'll find this code :

    $rules[$element_name]['email'] = true;

    add exactly below that code to activate the validation:

    $rules[$element_name]['email'] = true;
    if ($form_id == '11') {
    	$rules[$element_name]['blacklist_mail'] = true;
    }

    Finnaly it also filter the validation only for form 11 :).


    MachForm Support

    Posted 15 years ago #
  4. MvdL79
    Member

    Okay thanks!! You are a life-saver. :)
    I will give it a go!

    Posted 15 years ago #
  5. redityo

    yes they will get 'This email not allowed', to add custom message simply change those message.

    return 'This email not allowed';

    MachForm Support

    Posted 15 years ago #
  6. MvdL79
    Member

    Works great! Thanks! :)

    //edit

    Yeah I overlooked the message part, my bad! :)

    Posted 15 years ago #

RSS feed for this topic

Reply