Blog

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)
  {
    $regex='@^(https?://)?(www.)?([a-z0-9]([a-z0-9]|(-[a-z0-9]))*.)+[a-z]+$@i';  
    if (!preg_match($regex,$url)) $result=FALSE;	  
  }
  return $result;
}
add_filter( 'wpcf7_is_url', 'ikodes_contact7_check', 10, 2 );

Related Posts


February 1, 2019

Magento 2.x mail sent from unknown host name

If you are using Magento 2.2.4 or higher, either fresh or upgrade from 2.2.3, there is a bug that alters the email sender name. It will change from your presence in the store configuration General->Store Email Address to the server usernames. Something like this: 2.2.3 – salesteam@ikodes.net 2.2.4 – serverusername@myserver.ikdoes.net or on Stratus this might

January 21, 2019

Disable Payment Method for Specific Category in WooCommerce

Today we investigate the WooCommerce Checkout and explicitly at how to cripple an installment portal (for example PayPal) if certain item classifications are in the truck. add_filter( ‘woocommerce_available_payment_gateways’, ‘ikodes_unset_gateway_by_category’ ); function ikodes_unset_gateway_by_category( $available_gateways ) { global $woocommerce; $unset = false; $category_ids = array( 123, 111 ); foreach ( $woocommerce->cart->cart_contents as $key => $values ) {