Last active
April 23, 2021 10:20
-
-
Save andrewlimaza/1ae41d92490a7ca221170bda9be0a560 to your computer and use it in GitHub Desktop.
Add Sponsored Member's Code to Zapier Data [Paid Memberships Pro]
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 | |
/** | |
* Add Sponsored discount code to Paid Memberships Pro Zapier Integration data. | |
* This runs on the "After Checkout" trigger. Requires Sponsored/Group Members Add On - https://www.paidmembershipspro.com/add-ons/pmpro-sponsored-members/ | |
* Add this code to your site by following | |
*/ | |
function my_pmpro_add_sponsored_code_zapier( $data, $user_id, $level, $order ){ | |
// Bail if Sponsored Members not available. | |
if ( ! function_exists( 'pmprosm_getCodeByUserID' ) ) { | |
return $data; | |
} | |
$code_id = pmprosm_getCodeByUserID( $user_id ); | |
if ( ! empty( $code_id ) ) { | |
$discount_code = pmprosm_getDiscountCodeByCodeID( $code_id ); | |
$data['sponsored_code'] = $discount_code->code; | |
} | |
return $data; | |
} | |
add_filter( 'pmproz_after_checkout_data', 'my_pmpro_add_sponsored_code_zapier', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment