Skip to content

Instantly share code, notes, and snippets.

@sjaved87
Created December 2, 2015 12:55
Show Gist options
  • Save sjaved87/58464f783f1b7215cc75 to your computer and use it in GitHub Desktop.
Save sjaved87/58464f783f1b7215cc75 to your computer and use it in GitHub Desktop.
Membership 2 - Display expiry date.
<?php
function wpmu_display_membership_expiry_date($atts){
$returner = '';
$args = shortcode_atts( array('user_id' => '',
'membership' => ''
), $atts);
extract($args);
// only run if M2 is active
if ( defined( 'MS_PLUGIN' ) ){
$api = ms_api();
$subscription = $api->get_subscription($user_id, $membership);
if($subscription){
if( $subscription->expire_date )
$returner = MS_Helper_Period::format_date( $subscription->expire_date );
else
$returner = 'Never';
}else{
$returner = 'specify correct user id or membership id/slug/name';
}
return $returner;
}
}
add_shortcode('show_ms_expiry_date','wpmu_display_membership_expiry_date', 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment