Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Only charge billing amount for renewals.
- */
- function my_pmpro_checkout_level($level) {
- // Only continue for recurring levels.
- if( ! pmpro_isLevelRecurring( $level ) ) {
- return $level;
- }
- global $wpdb, $current_user;
- // Does this user have a membership record for this level within the past 3 months?
- $enddate = date('Y-m-d H:i:s', strtotime('-3 months', current_time('timestamp')));
- $sql = "SELECT COUNT(id) FROM {$wpdb->pmpro_memberships_users} WHERE user_id = {$current_user->ID} AND membership_id = {$level->id} AND enddate > '{$enddate}' LIMIT 1";
- $old_level = $wpdb->get_var($sql);
- if($old_level) {
- $level->initial_payment = $level->billing_amount;
- }
- $level->cycle_number = 0;
- $level->billing_amount = 0;
- $level->cycle_period = '';
- return $level;
- }
- add_action('pmpro_checkout_level', 'my_pmpro_checkout_level');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement