Skip to content

Instantly share code, notes, and snippets.

@DumahX
Created May 12, 2022 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DumahX/e60f50ee3c7fe0da1a8f9b954ae2e062 to your computer and use it in GitHub Desktop.
Save DumahX/e60f50ee3c7fe0da1a8f9b954ae2e062 to your computer and use it in GitHub Desktop.
<?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