Does assign a membership level when purchasing an EDD product work in 3.0?
-
I’m using a recipe from Paid Memberships Pro (PMPRO) that allows visitors to assign a membership level to members when purchasing an EDD product.
Will this code work on EDD’s side after upgrading to 3.0? Just to note that this code currently works like a charm.
function my_pmpro_change_level_edd_update_payment_status( $payment_id, $new_status, $old_status ) { // Basic payment meta. $payment_meta = edd_get_payment_meta( $payment_id ); // Product ID with custom Membership Level Array - Change parameters for that level on the fly such as an expiration date. $product_levels = array( 86150 => array( 'membership_id' => 9, // integer - Required 'user_id' => $payment_meta['user_info']['id'], 'billing_amount' => '156.00', // float (string) 'startdate' => current_time( 'mysql' ), // string (date) 'enddate' => date( "Y-m-d 00:00:00", strtotime( "+1 year" ) ) ), 86194 => array( 'membership_id' => 8, // integer - Required 'user_id' => $payment_meta['user_info']['id'], 'billing_amount' => '120.00', // float (string) 'startdate' => current_time( 'mysql' ), // string (date) 'enddate' => date( "Y-m-d 00:00:00", strtotime( "+1 year" ) ) ), 86195 => array( 'membership_id' => 7, // integer - Required 'user_id' => $payment_meta['user_info']['id'], 'billing_amount' => '96.00', // float (string) 'startdate' => current_time( 'mysql' ), // string (date) 'enddate' => date( "Y-m-d 00:00:00", strtotime( "+1 year" ) ) ), ); $user_id = $payment_meta['user_info']['id']; if ( $new_status == 'publish' ) { // Order is complete. foreach ( $payment_meta['cart_details'] as $key => $item ) { if ( ! empty( $product_levels[$item['id']] ) ) { pmpro_changeMembershipLevel( $product_levels[$item['id']], $payment_meta['user_info']['id'] ); // If a user buys the product with ID of 27, change their level to 1. } } } else { // Remove the level for any of the other statuses: pending, processing, revoked, failed, abandoned, preapproval, cancelled, refunded pmpro_changeMembershipLevel( 0, $user_id ); } } add_action( 'edd_update_payment_status', 'my_pmpro_change_level_edd_update_payment_status', 10, 3 );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Does assign a membership level when purchasing an EDD product work in 3.0?’ is closed to new replies.