Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Code demo/proof of concept
- Premise:
- PMPro Sponsored Members dynamic charging. ONLY charge the parent account when a child account actually signs up using the sponsor code.
- Basically we're charging the parent account CC when a child account signs up with the code.
- Limitations...
- * Parent account MUST have made an initial purchase
- * Currently ONLY works with Stripe
- * Code and behavior should be considered HIGHLY EXPERIMENTAL and should be TESTED before use.
- * Could cause other issues with reports (untested)
- * Parent account does not receive emails when child account checks out (and their CC is charged)
- */
- function my_pmpro_after_checkout($user_id, $morder)
- {
- $parent = pmprosm_getSponsor($user_id);
- if(!empty($parent))
- {
- $parent_order = new MemberOrder();
- $parent_order->getLastMemberOrder($parent->ID);
- $child_order = new MemberOrder();
- $child_order->InitialPayment = 10;
- $child_order->gateway = "stripe";
- $child_order->user_id = $parent->ID;
- $child_order->membership_id = 8;
- $child_order->notes = "This is a child order for ". $user_id;
- $parent_order->Gateway->charge($child_order);
- }
- }
- add_action('pmpro_after_checkout', 'my_pmpro_after_checkout', 10, 2);
- function pmpro_sponsored_member_settings {
- $pmprosm_sponsored_account_levels = array(
- 7 => array(
- 'main_level_id' => 7,
- 'sponsored_level_id' => array(8),
- 'seats' => 0, //0 means unlimited
- ),
- );
- }
- }
- add_action('init', 'pmpro_sponsored_member_settings');
Add Comment
Please, Sign In to add comment