Skip to content

Instantly share code, notes, and snippets.

@KristaButler
Created September 15, 2022 15:41
Show Gist options
  • Save KristaButler/10bd4f2e381174fd6674a18178e72bc8 to your computer and use it in GitHub Desktop.
Save KristaButler/10bd4f2e381174fd6674a18178e72bc8 to your computer and use it in GitHub Desktop.
Membership Expiration Date Shortcode
<?php
//Shortcode Example: [mepr-sub-expiration membership='123']
function mepr_sub_expiration_shortcode($atts = [], $content = null, $tag = '') {
$sub_expire_html = '';
if($atts['membership'] && is_numeric($atts['membership'])) {
$date_str = MeprUser::get_user_product_expires_at_date(get_current_user_id(), $atts['membership']);
if ($date_str) {
$date = date_create($date_str);
$sub_expire_html = "<div>Expires: " . date_format($date,"Y/m/d") . "</div>";
}
}
return $sub_expire_html;
}
add_shortcode('mepr-sub-expiration', 'mepr_sub_expiration_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment