Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewlimaza/1ae41d92490a7ca221170bda9be0a560 to your computer and use it in GitHub Desktop.
Save andrewlimaza/1ae41d92490a7ca221170bda9be0a560 to your computer and use it in GitHub Desktop.
Add Sponsored Member's Code to Zapier Data [Paid Memberships Pro]
<?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