The WooCommerce Membership has some conditionals but I can't combine them to specifically test whether a specific member has access to specific content.
$post_id = get_the_ID(); // this post is available to access level 'insights' but *not* available to a member with access level 'resources'
// if post content is restricted
if ( wc_memberships_is_post_content_restricted($post_id) ) {
// returns true for *any* restricted content (whether restricted for this member or not)
// check if user has membership
$user_id = get_current_user_id(); // this member has access level 'resources' but not 'insights'
if ( wc_memberships_is_user_active_member( $user_id, 'resources' ) ){
/// will return *true* dependent on user but *not* dependent on content
echo "You";
} else {
echo 'Not you ';
}
}
always returns 'You'
so how do I check whether this user has the access level for this content?
In plain English I think I need to find out what restrictions are placed on the post content but there doesn't seem to be a conditional for that (which is very odd)