How do I get the ccaps required for a specific page?

I’m trying to write a function to check if the current logged in user’s custom capabilities match the required custom capabilities for a page. Is there a function to get the s2member_ccaps_req for a given post ID?

I can see in the database that for the meta key ‘s2member_ccaps_req’, there is a meta_value of 'a:1:{i:0;s:11:“ccap_is_here”;}. How can I just get the ‘ccap_is_here’ bit from that field, since the values before it differ from post to post?

Is there an S2Member PHP function to get this value for a given post ID?

1 Like

Yes, you can use the WordPress get_post_meta() function for that:

$array = get_post_meta( $post_ID, 's2member_ccaps_req' );
print_r( $array ); // See what's inside

Hi, I’m doing the same check in my site, and … will be very appreciated if you share any result of your code with me… BR, Dima

You are responding to a 3 year old post…don’t count on a reply.