1. Home
  2. Knowledge Base
  3. WooCommerce Wholesale Lead Capture
  4. Account
  5. How To Send User Information To Zapier On Approval

How To Send User Information To Zapier On Approval

Zapier is a very powerful tool that acts as the agent in between 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 the 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 set up 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.

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support