1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Email Validation Rule 1.0.0

Use custom email validation rule such as regular expression.

  1. semprot
    Compatible XF Versions:
    • 1.5
    License:
    Creative Commons license
    Visible Branding:
    No
    No download is needed :)
    ___________________


    Do you need regular expression to validate user's email?
    Now you can do it, using a file edit :)
    • Please backup the file before modifying
    You must edit this file :
    Code:
    /library/XenForo/Helper/Email.php
    Find these lines :
    PHP:
        public static function isEmailValid($email)
        {
            
    $validator = new Zend_Validate_EmailAddress();
            
    $validator->getHostnameValidator()
                ->
    setValidateTld(false)
                ->
    setValidateIdn(false);
            return 
    $validator->isValid($email);
        }
    Change as you wish, such as :

    (this pattern is just a sample. Do not use it without knowing what it means)
    PHP:
     
        
    public static function isEmailValid($email)
        {
            if (
    '' != $email) {
                
    $your_own_pattern '/^([0-9]+)/iU';
                if (
    preg_match($your_own_pattern$email)) {
                    return 
    false;
                }
            }

            
    $validator = new Zend_Validate_EmailAddress();
            
    $validator->getHostnameValidator()
                ->
    setValidateTld(false)
                ->
    setValidateIdn(false);
            return 
    $validator->isValid($email);
        }