Last active
May 2, 2022 09:52
-
-
Save flyingwebie/d97f26e09cbb788e66b94d61f63d612f to your computer and use it in GitHub Desktop.
Helpful function for MemberPress with Oxygen Builder.
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 | |
function mpr_get_expire_date() { | |
if(is_user_logged_in()){ | |
$user = MeprUtils::get_currentuserinfo(); | |
$subscriptions = $user->active_product_subscriptions('transactions'); | |
if(!empty($subscriptions)) { | |
foreach($subscriptions as $s){ | |
// Get Today Date | |
$today = date("d-m-Y"); | |
$today_str = strtotime($today); | |
// Get Start Date and convert it to string | |
// At the moment we DO NOT USE THE START DATE | |
//$start = $s->created_at; | |
//$start_str = strtotime($start); | |
// Get Expire Date and convert it to string | |
$expire = $s->expires_at; | |
$expire_str = strtotime($expire); | |
// Get Free Product ID | |
$free = $s->product_id; | |
// Check if the TODAY DATE is smaller than EXPIRE DATE | |
if($today_str <= $expire_str && $free != '261'){ | |
// If it is TRUE it means that the membership is still active | |
return "mpr-active"; | |
} else { | |
// If it is FALSE it means that the membership IS NOT active | |
return "mpr-inactive"; | |
} | |
} | |
} else { | |
return 'mpr-inactive'; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment