Skip to content

Instantly share code, notes, and snippets.

@andrija-naglic
Created September 3, 2018 20:43
Show Gist options
  • Save andrija-naglic/8ed869affdaf80b1af9f71af75de01f0 to your computer and use it in GitHub Desktop.
Save andrija-naglic/8ed869affdaf80b1af9f71af75de01f0 to your computer and use it in GitHub Desktop.
WP MemberPress - get list of memberships that can access a restricted content
<?php
$the_post_object = get_post( $post_id );
$access_list = MeprRule::get_access_list( $the_post_object );
$product_ids = (isset($access_list['membership']) && !empty($access_list['membership'])) ? $access_list['membership'] : array();
/*
$acces_list returns: ["membership" => [1,2], "member" =>["foo"]]
$products_ids contains an array of Membership IDs that can access this content
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment