Created
May 12, 2022 13:15
-
-
Save DumahX/e60f50ee3c7fe0da1a8f9b954ae2e062 to your computer and use it in GitHub Desktop.
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 | |
add_shortcode('mepr-list-unsubscribed-memberships', function() { | |
$content = ''; | |
$user = MeprUtils::get_currentuserinfo(); | |
$memberships = MeprProduct::get_all(); | |
$unsubscribed_memberships = array(); | |
if(!$user) { | |
return $content; | |
} | |
if(is_array($memberships)) { | |
foreach($memberships as $membership) { | |
if(!$user->is_already_subscribed_to($membership->ID)) { | |
$unsubscribed_memberships[] = $membership; | |
} | |
} | |
} | |
if(!empty($unsubscribed_memberships)) { | |
$content .= '<ul>'; | |
foreach($unsubscribed_memberships as $membership) { | |
$content .= '<li>'; | |
$content .= '<a href="' . $membership->url() . '">' . $membership->post_title . '</a>'; | |
$content .= '</li>'; | |
} | |
$content .= '</ul>'; | |
} | |
return $content; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment