Ikodes Technology

WP Contact Form 7 create a custom URL validation
In WP the Contact Form 7 is a standout amongst the most famous modules for making contact shapes. One thing that you may have seen however is that the approval of the URL field won't fall flat when you anticipate that they will come up short. For instance, with the URL estimation of https://ikodes.net, the module will think about this as a substantial URL, despite the fact that, the URL esteem is missing best level space part. The answer to this issue is to have a custom approval for the URL field. This article will demonstrate to you generally accepted methods to accomplish that.

Including our own URL approval utilizing wpcf7_is_url channel

Our custom URL approval will be genuinely straightforward. On the off chance that the default URL approval of the module is legitimate, we complete one extra approval utilizing a regex articulation that will attempt to approve a space name. There are numerous standard articulations on the web for space name approval, the one I use in the code beneath appears to work entirely well. On the off chance that regex approval bombs, at that point we set $result to FALSE, which will flag the module to show "URL appears to be invalid." blunder message.

In the functions.php of your theme, add the following code:

function ikodes_contact7_check( $result, $url )
if ($result)
if (!preg_match($regex,$url)) $result=FALSE;
return $result;
add_filter( 'wpcf7_is_url', 'ikodes_contact7_check', 10, 2 );

Author Bio

ikodes Technology

Manager of Marketing for Red Stag Fulfillment, an ecommerce fulfillment warehouse that was born out of ecommerce. He has years of experience in ecommerce and business development. In his free time, Jake enjoys reading about business and sharing his own experience with others.

Go Back

Expand Your Digital Horizons With Us

Start a new project or take an existing one to the next level. Get in touch to start
small, scale-up, and go Agile.

    Math Captcha 5 + 5 =