Created
September 15, 2022 15:41
-
-
Save KristaButler/10bd4f2e381174fd6674a18178e72bc8 to your computer and use it in GitHub Desktop.
Membership Expiration Date Shortcode
This file contains 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 | |
//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