Created
December 2, 2015 12:55
-
-
Save sjaved87/58464f783f1b7215cc75 to your computer and use it in GitHub Desktop.
Membership 2 - Display expiry date.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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