Validate Number field in Contact Form 7

Allow numbers only in ‘number’ field in Contact Form 7 plugin, add the following code in your functions.php

Validate Numbers in Contact Form 7
This is for 10 digit numbers

function is_number( $result, $tag ) {
$type = $tag['type'];
$name = $tag['name'];

if ($name == 'request-phone') {
$stripped = preg_replace( '/\D/', '', $_POST[$name] );
$_POST[$name] = $stripped;
if( strlen( $_POST[$name] ) != 10 ) { // Number string must equal this
$result['valid'] = false;
$result['reason'][$name] = $_POST[$name] = 'Enter 10 digit phone number.';
return $result;

add_filter( 'wpcf7_validate_text', 'is_number', 10, 2 );
add_filter( 'wpcf7_validate_text*', 'is_number', 10, 2 );

How to call it in the admin section

[number request-phone]

Replace “request-phone” with your field name.

Executing PHP inside a widget in WordPress

To enable php in Widgets, you add the following code in your theme’s functions.php

function execute_php($html){
    if(strpos($html,"<"."?php")!==false) {
    return $html;

Redirect Link to Mobile Website using .htaccess

Just add the following code in your .htaccess file

RewriteEngine on
RewriteBase /

# prevent looping
RewriteCond %{HTTP_HOST} !^$

# if the browser accepts these mime-types, it's definitely mobile, or pretending to be
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR]

# a bunch of user agent tests
RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC]

# rewrite rules here
RewriteRule .?{REQUEST_URI}  [L,R=302]