} else { ?> <?php esc_html_e('N/A', WC_Memberships::TEXT_DOMAIN); ?> <?php } ?> </td> <td class="membership-status" style="text-align:left; white-space:nowrap;" data-title="<?php esc_attr_e('Status', WC_Memberships::TEXT_DOMAIN); ?> "> <?php echo esc_html(wc_memberships_get_user_membership_status_name($membership->get_status())); ?> </td> <?php /** * Fires after the membership columns, before the actions column in my memberships table * * @since 1.0.0 * @param WC_Memberships_User_Membership $user_membership */ do_action('wc_memberships_my_memberships_columns', $membership); ?> <td class="membership-actions" data-title="<?php esc_attr_e('Actions', WC_Memberships::TEXT_DOMAIN);
/** * Handle post status transitions for user memberships * * @since 1.0.0 * @param string $new_status New status slug * @param string $old_status Old status slug * @param WP_Post $post Related WP_Post object */ public function transition_post_status($new_status, $old_status, WP_Post $post) { if ('wc_user_membership' != $post->post_type || $new_status == $old_status) { return; } // Skip for new posts and auto drafts if ('new' == $old_status || 'auto-draft' == $old_status) { return; } $user_membership = $this->get_user_membership($post); $old_status = str_replace('wcm-', '', $old_status); $new_status = str_replace('wcm-', '', $new_status); $status_note = sprintf(__('Membership status changed from %s to %s.', WC_Memberships::TEXT_DOMAIN), wc_memberships_get_user_membership_status_name($old_status), wc_memberships_get_user_membership_status_name($new_status)); $optional_note = $this->get_membership_status_transition_note(); // prepend optional note to status note, if provided $note = $optional_note ? $optional_note . ' ' . $status_note : $status_note; $user_membership->add_note($note); switch ($new_status) { case 'cancelled': update_post_meta($user_membership->get_id(), '_cancelled_date', current_time('mysql')); break; case 'paused': update_post_meta($user_membership->get_id(), '_paused_date', current_time('mysql')); break; case 'active': // Save the new membership end date and remove the paused date. // This means that if the membership was paused, or, for example, // paused and then cancelled, and then re-activated, the time paused // will be added to the expiry date, so that the end date is pushed back. if ($paused_date = $user_membership->get_paused_date()) { $user_membership->set_end_date($user_membership->get_end_date()); delete_post_meta($user_membership->get_id(), '_paused_date'); } break; } /** * Fires when user membership status is updated * * @since 1.0.0 * @param WC_User_Membership $user_membership * @param string $old_status Old status, without the wcm- prefix * @param string $new_status New status, without the wcm- prefix */ do_action('wc_memberships_user_membership_status_changed', $user_membership, $old_status, $new_status); }