Created
August 29, 2014 16:41
-
-
Save pippinsplugins/f1fa0fa83d556fd31cdc to your computer and use it in GitHub Desktop.
Basic Ontraport referral tracking for Restrict Content Pro
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 | |
/* | |
* Plugin Name: Restrict Content Pro - OntraPort Referral Tracking | |
* Description: Very basic referral tracking for onraport and Restrict Content Pro | |
*/ | |
function pw_rcp_ontraport_referrals( $payment_id, $args, $amount ) { | |
global $rcp_options; | |
$payments = new RCP_Payments; | |
$last_payment = $payments->last_payment_of_user( $args['user_id'] ); | |
// Check if this is the subscribers first payment. We only send referrals on the first one | |
if( $last_payment && $layment_payment->id != $payment_id ) { | |
return; | |
} | |
$user_object = get_userdata( $args['user_id'] ); | |
$email = $user_object->user_email; | |
$first_name = $user_object->first_name; | |
$last_name = $user_object->last_name; | |
$item_price_1 = rcp_get_subscription_price( rcp_get_subscription_id( $args['user_id'] ) ); | |
$external_id_1 = rcp_get_subscription_name( rcp_get_subscription_id( $args['user_id'] ) ); | |
$referral_url = "https://postmasculine.ontraport.net/p?order_id={$payment_id}&E-Mail={$email}&First_Name={$first_name}&Last_Name={$last_name}&item_external_id_1={$external_id_1}&item_price_1={$item_price_1}&item_qty_1=1"; | |
// Send the request to OntraPort | |
wp_remote_get( $referral_url ); | |
} | |
add_action( 'rcp_insert_payment', 'pw_rcp_ontraport_referrals', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment