Gravityforms limit submission – once for user, unlimited for guest

	public function context() {

		// rule targets specific user, if this user is different we don't need to test the rule
		if ( $this->user_id != 'all' ) {
			if ( $this->user_id != get_current_user_id() ) {
				return false;
		if($this->user_id == "all")
			    return false;

		return true;

File: gp-limit-submissions/includes/GPLS_Rule_User.php


How to add Buy Now button on Product page – WordPress/woocommerce?

Change && to &&

add_filter('woocommerce_add_to_cart_redirect', 'malpani_redirect_checkout_add_cart');

        function malpani_redirect_checkout_add_cart()
            if (isset($_POST["buynow"]) && $_POST["buynow"] === "2") {
                return wc_get_checkout_url();


        add_filter('woocommerce_after_add_to_cart_button', 'malpani_add_buy_button');
        function malpani_add_buy_button()
        echo '<input id="buynowinput" name="buynow" value="1" hidden>
            <button type="button" id="buy_now" class="buy_now button">Buy Now</button>
                jQuery(document).ready(function ($) {
                    $("#buy_now").click(function (e) {

How to edit wordpress woocommerce order api responses (legacy + latest)

add_filter('woocommerce_api_order_response', 'harsh_add_shipping_phone_legacy', 99, 1);
function harsh_add_shipping_phone($order_data)
$order_data["billing_address"]["email"] = "XXXX";
$shipping_phone = get_post_meta($order_data["id"],"_shipping_phone",1);
if($shipping_phone!==false &amp;&amp; strlen($shipping_phone))
$order_data["billing_address"]["biller_phone"] = $order_data["billing_address"]["phone"];
$order_data["shipping_address"]["phone"] = $shipping_phone;
$order_data["billing_address"]["phone"] = $shipping_phone;
foreach($order_data["line_items"] as $k=>$v)
return $order_data;
//// FOR latest api
function wc_add_rest_order_meta( $response, $post, $request ) {
$order_data = $response->get_data();
$order_data["billing"]["email"] = "XXXX";
$sp = array_search('_shipping_phone', array_column($order_data["meta_data"], 'key'));
$order_data["billing"]["biller_phone"] = $order_data["billing"]["phone"];
$order_data["shipping"]["phone"] = $order_data["meta_data"][$sp]->value;
$order_data["billing"]["phone"] = $order_data["meta_data"][$sp]->value;
foreach($order_data["line_items"] as $k=>$v)
$response->data = $order_data;
return $response;	
function wc_add_rest_order_meta2( $response, $post, $request ) {
foreach($response as $oneorder)
$order_data = $oneorder->get_data();
$order_data["billing"]["email"] = "XXXX";
$sp = array_search('_shipping_phone', array_column($order_data["meta_data"], 'key'));
$order_data["billing"]["biller_phone"] = $order_data["billing"]["phone"];
$order_data["shipping"]["phone"] = $order_data["meta_data"][$sp]->value;
$order_data["billing"]["phone"] = $order_data["meta_data"][$sp]->value;
foreach($order_data["line_items"] as $k=>$v)
$oneorder->data = $order_data;
return $response;	
add_filter( 'woocommerce_rest_prepare_shop_order_object', 'wc_add_rest_order_meta', 10, 3 );
add_filter( 'woocommerce_rest_prepare_shop_orders_object', 'wc_add_rest_order_meta2', 10, 3 );

Standalone script to print all published post IDs in WordPress

header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
define( 'SHORTINIT', true );
require( 'wp-load.php' );
$qr = 'SELECT * FROM `'.$wpdb->prefix . 'posts` where `post_type`="post" and `post_status`="publish"';
$posts = $wpdb->get_results( $qr);
//$pr = implode(",",array_column($posts,"ID"));
$pr = json_encode(array_column($posts,"ID"));
echo $pr;

Radio buttons CSS for wordpress elementor form markup

[type="radio"]:checked + label:before {
background: #bc6060;
box-shadow: 0 0 0 0.25em #000;
[type="radio"]:focus + label:after {
content: '\0020\2190';
font-size: 1.5em;
line-height: 1;
vertical-align: -0.125em;
[type="radio"] {
border: 0; 
clip: rect(0 0 0 0); 
height: 1px; margin: -1px; 
overflow: hidden; 
padding: 0; 
position: absolute; 
width: 1px;
label {
display: block;
cursor: pointer;
line-height: 2;
font-size: 1.2em;
[type="radio"] + label {
display: block;
[type="radio"] + label:before {
content: '';
display: inline-block;
width: 1em;
height: 1em;
vertical-align: -0.25em;
border-radius: 1em;
border: 0.125em solid #fff;
box-shadow: 0 0 0 0.15em #000;
margin-right: 0.75em;
transition: 0.5s ease all;

How to migrate Customers from Magento2 to WordPress?

Lets break it into 2 parts:

a. Migrate Customer data
b. Migrate Customer Passwords

1) Migrate Customer Data from Magento2 to WordPress

This is rather easy to be honest, there are several plugins for importing data from CSV and then mapping the CSV fields.

My recommended plugin is Customer/Order/Coupon CSV Import Suite by SkyVerge

It basically does everything from customer email to customer address data. It also provides column mapping and custom attribute import for all users. Also comes with multiple configuration options.

Best Free Alternative is
But in this one, you can not import magento2 passwords as of v
I will update about the solution very soon. So as of now only paid option is there.

2) Migrate Customer Password from Magento2 to WordPress

This wordpress plugin checks and updates passwords of users migrated from Magento2 to WordPress
Plugin Link:


  1. user_pass column will have this kind data from Magento2 dcbdc524f215fd054502dcad5a23a702ec029c02ff8d7051d049f76e29927f8b:C8yVqeuPfkHWvkmipx0iKLPtOUGETpLL:1
  2. usermeta table must have a meta_key “migrated_cs” for this user, meta_value can be anything positive
  3. This plugin file password-migrator.php should be in wp-content/plugins and must be an active plugin

What is does?

For new wordpress based users which dont have anything to do with magento2, it doesnt do anything

For all migrated users (those have the key “migrated_cs”), this plugin checks if input password matches old password from magento2 or not, if matched, it clears the key migrated_cs and updates the password using wordpress’ algorithm ; else results false.

How to wipe all the tables and data in MySQL? Clean whole database

SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;

Will not work via phpmyadmin or any script. this has to be run in cmd/terminal

Quick Command



How to filter and validate pincode in Indian woocommerce?

By default, Woocommerce only validates ZIP code of few countries only. Woocommerce stores in India, are thus invalidated in case of PINCODE inputs from customers. Here is how you can enable checking of pincode for India woocommerce:

Put the following code in your custom function file or child theme functions.php

function validate_indian_postcode($valid, $postcode, $country){
$valid = (bool) preg_match( '/^([0-9]{6})$/', $postcode );
// checks your $postcode, if valid $valid will be true because of preg_match else false
return $valid;


Testing Configuration for Paytm Gateway Plugin India

Paytm Payment Gateway Testing Data

Online payment solutions for all your transactions by Paytm Woocommerce Plugin

Download the plugin here:

Enable/Disable Enable Paytm Payments.
This controls the title which the user sees during checkout.

The best payment gateway provider in India for e-payment through credit card, debit card & netbanking.
This controls the description which the user sees during checkout.

Merchant Identifier
Merchant Identifier
<provided link below>
Merchant Id Provided by Paytm

Secret Key
Secret Key
<provided link below>
Merchant Secret Key Provided by Paytm

Website Name Provided by Paytm

Industry Type
Industry Type
Industry Type Provided by Paytm

Channel ID
Channel ID
Channel ID Provided by Paytm

Transaction URL
Transaction URL
Transaction URL Provided by Paytm

Transaction Status Url
Transaction Status Url
Transaction Status URL Provided by Paytm

API Keys

You can get your keys here

API keys are unique credentials issued to every merchant. While MID is used as an identification used for all exchange correspondence, merchant key is used to encrypt every API request to Paytm and decrypt every response from Paytm. Ensure that you keep the merchant key on server side and should not be shared with anyone. In case API keys are compromised, please reach out to our helpdesk to get new API keys.

  • MID (Merchant ID) – Unique identifier issued to every merchant.
  • Merchant Key – This is a unique secret key used for secure encryption of every request. This needs to be kept on server side and should never be shared with anyone.
  • Industry Type ID – This is part of bank and paymode configuration done wrt to an account.
  • Website – This parameter is used to support multiple callback URLs to post the transaction response. Each URL needs to be mapped to a website parameter.

Test API Details are something like this:

  • Test Merchant ID WArHEFXXXXXXXXXXXXXX <–wont work
  • Test Account Secret Key XXXXXXXXOcv1u7P2 <- wont work

Testing Resources / Testing Instruments


  • Testing Debit/Credit Card
Card NumberAny Visa or Master Card
Expiration Month & YearAny Future month and Year
  • Testing Paytm Wallet Details
Mobile Number77777 77777
OTPDoesn’t require 2nd factor authentication489871
  • Testing Netbanking Details
Bank NameAndhra Bank
User IDtest

In case you are testing on production environment, use live paymode details to complete the transaction. Once the transaction is successful, you can initiate refund from the dashboard.

Your PHP installation appears to be missing the MySQL extension, required by WordPress

The error message “Your PHP installation appears to be missing the MySQL extension which is required by WordPress” can appear when you are using a PHP version which is incompatible with your scripts version. Meaning your WordPress installation is most likely outdated.

Since the ‘MySQL’ extension is no longer supported from PHP 7.0 and beyond, changing your PHP version to 5.6 or lower will fix the issue. This can be done via your website’s control panel’s PHP Configuration section.

So, let’s do it first and then we will see some probable causes of this error.


Step 1- Login to your Cpanel.

Step 2- Find PHP PEAR Packages and click on it. and then click on show available modules.

Step 3- Find MYSQL and install the 3 extensions shown in the image above.

Step 4- Now Go to select PHP version.

Step 5- Now find MySQL (Use Ctrl + F), select it and save it.

That’s it. The problem is fixed. Let’s get to some probable causes of this error.

Probable causes of this error.

1. PHP’s MySQL extension not installed.

The quickest way to check if your PHP has MySQL support is to put the following code into a file called info.php in your site and access it from a browser.


A MySQL section like this will be shown.
If it’s not shown there, then you don’t have the PHP’s MySQL extension installed.

In Ubuntu servers and RedHat compatible servers, use the following commands respectivly:

# apt-get install php5-mysqlnd
# yum install php-mysql

2. Check if PHP’s MySQL extension directory is misconfigured.

Another cause of the ‘Your PHP installation appears to be missing the MySQL extension which is required by WordPress’. could be that the PHP extension directory is not configured properly.

In order to fix this, locate which PHP.ini file is being loaded and ensure that the appropriate “extension_dir” value is being used. So let’s open up the info.php file we created in Step 1 via our web browser.

Look for the line called “Loaded Configuration File”. The file path noted there is the actual location to the PHP configuration file.

Now, look for the entry called “extension_dir“. It should either be commented, or it should have the correct path to PHP extensions. It should never be left blank.

If you are not sure, just comment the line, and restart the web server.

Simply updating PHP and WordPress might also solve the problem.

In case you are running PHP 5, run the following commands:

apt-get update
apt-get install php-mysql

Restart the appropriate service for the changes to take effect.

This may have solved your problem. Feel free to comment below.

Thank You.