• Resolved readyallcz

    (@readyallcz)


    Hello, I need to update a validation function in validation-functions.php file.

    I dont want to lose these changes with future updates. Is there any way I can override this function, i.e. in my child theme functions.php? This is the original function I need to override.

    function wpcf7_is_tel( $tel ) {
    	$pattern = '%^[+]?' // + sign
    		. '(?:\([0-9]+\)|[0-9]+)' // (1234) or 1234
    		. '(?:[/ -]*' // delimiter
    		. '(?:\([0-9]+\)|[0-9]+)' // (1234) or 1234
    		. ')*$%';
    
    	$result = preg_match( $pattern, trim( $tel ) );
    	return apply_filters( 'wpcf7_is_tel', $result, $tel );
    }

    Thank you for any help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, readyallcz, I’m another CF7 user.

    You can hook into the wpcf7_is_tel filter like the following:

    // define the callback function 
    function filter_wpcf7_is_tel( $result, $tel ) { 
        // manipulate the result 
        return $result; 
    }; 
             
    // add the filter 
    add_filter( 'wpcf7_is_tel', 'filter_wpcf7_is_tel', 10, 2 );
    Thread Starter readyallcz

    (@readyallcz)

    Hello, thank you for your help.

    Code is working exactly as I needed.

    Have a nice day.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Validation change’ is closed to new replies.