How To Send User Information To Zapier On Approval

Zapier is a very powerful tool that acts as the agent inbetween API’s. If you haven’t heard of it, and you are in need of shifting data around from one place to another, definitely check it out.

This guide is an advanced guide and I’m assuming you have knowledge of PHP coding and how APIs and Webhooks work.

With that out of the way, we recently had a case where we had to send user the wholesale customer’s email and name to a special wholesale mailing list in Campaign Monitor on approval. This is a task that is very well suited to Zapier because it has integrations already with all the major email marketing platforms.

The only part missing was the ability to get the data out of WordPress and over to Zapier, we chose to do this with a simple webhook POST.

In Zapier you can setup a webhook to collect data, I’ll leave the explanation of this part to them:

What we’re interested in is how to send the data over to Zapier and here is a code snippet of how to do it when a new wholesale user is approved:

function wwlcSendWebhook( $user ) {
    $url = 'https://zapier.com/hooks/catch/XXXXXXXX';; // replace this with your Zapier provided webhook URL

    $args = array(
        'method' => 'POST',
        'body' => array(
            'first_name' => $user->user_firstname,
            'last_name' => $user->user_lastname,
            'email_address' => $user->user_email,
        )
    );

    wp_remote_post( $url, $args );
}

add_action( 'wwlc_action_after_approve_user', 'wwlcSendWebhook', 10, 1 );

Add the above code to your functions.php and it will send the user’s data to the defined Zapier webhook URL whenever a wholesale customer user is Approved.

in WooCommerce Wholesale Lead Capture

Solve The Big Three Problems With Wholesaling In WooCommerce

Add wholesale pricing to products   Streamline your ordering   Register & manage wholesale customer

Explore The Plugin Suite  

[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']