Created
April 1, 2020 12:22
-
-
Save JarrydLong/8c1c79abd2c1ec68b277df3ee9aaecea to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* We'll add in a check to see which membership level was purchased. | |
* We can then specify which webhook each level should send data to. | |
* If it doesn't meet the criteria of our check, we'll use the default | |
* in the settings page. | |
* That URL is then added to the $data array | |
*/ | |
function mypmpro_multiple_zapier_webhooks_after_order( $data, $order, $user_id ){ | |
if( isset( $order->membership_id ) ){ | |
$level_id = intval( $order->membership_id ); | |
if( $level_id == 1 ){ | |
$data['webhook_url'] = 'https://zapier.com/webhook_url_1'; | |
} | |
} | |
return $data; | |
} | |
add_filter( 'pmproz_added_order_data', 'mypmpro_multiple_zapier_webhooks_after_order', 10, 4 ); | |
/** | |
* We'll retrieve the URL from the $data array if it's available and use it | |
*/ | |
function mypmpro_custom_webhook_url( $url, $data ){ | |
if( isset( $data['webhook_url'] ) ){ | |
$url = $data['webhook_url']; | |
} | |
return $url; | |
} | |
add_filter( 'pmproz_prepare_request_webhook', 'mypmpro_custom_webhook_url', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment