Created
April 3, 2019 12:34
-
-
Save andrewlimaza/d9b8d01751867f3acfa7f4109f3130c8 to your computer and use it in GitHub Desktop.
Send WordPress user meta data to Zapier.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This requires version 1.3+ for WP Zapier Plugin - https://yoohooplugins.com/plugins/zapier-integration/ | |
* You may follow this function as a guide to send user meta to Zapier, or any other data really. | |
* This code runs whenever a user's profile is updated. | |
* Add the below code to a custom plugin/Child Theme function.php | |
*/ | |
function my_wp_zapier_send_meta( $array, $user, $user_id ) { | |
// Get the user meta - value will be "Cherie" | |
$spouse_name = get_user_meta( $user_id, 'spouse_name', true ); | |
// $meta_key = get_user_meta( $user_id, 'meta_key', true ); | |
// Add data to the array we are sending to Zapier or another service/webhook. | |
$array['spouse_name'] = $spouse_name; | |
return $array; | |
} | |
add_filter( 'wpzp_send_data_profile_update_array', 'my_wp_zapier_send_meta', 10, 3 ); |
@mfitzz10, your code looks correct to me. If you var_dump the data does it show correct? Once adding to the array I'd recommend redoing your Zapier steps (to ensure this data gets captured).
Also, this data gets cached for an hour.
Sorry, not really familiar with PHP, how would I use var_dump?
Please open a support ticket on https://yoohooplugins.com/support and we'll try help you if we can or advise you further.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Andrew, thanks for the quick reply I tried using that hook (code below) but not having any luck, any ideas?
function my_wp_zapier_send_meta( $array, $user, $user_id ) { //Get the user meta $distributor_name = get_user_meta( $user_id, 'distributor_name', true ); $account_number = get_user_meta( $user_id, 'account_number', true ); $zip_code = get_user_meta( $user_id, 'zip_code', true ); // Add data to the array we are sending to Zapier or another service/webhook. $array['distributor_name'] = $distributor_name; $array['account_number'] = $account_number; $array['zip_code'] = $zip_code; return $array; } add_filter( 'wpzp_send_data_register_array', 'my_wp_zapier_send_meta', 10, 3 );