Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basic Ontraport referral tracking for Restrict Content Pro
<?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