latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Get Custom Capability Associated with a Post

Home Forums Community Forum Get Custom Capability Associated with a Post

This topic contains 1 reply, has 2 voices. Last updated by  ekarma (Volunteer Moderator) 3 years, 3 months ago.

Topic Author Topic
Posted: Friday Oct 4th, 2013 at 4:35 pm #60156
PRoman
Username: puppetsmith

First time posting on the forum…love s2member…it’s organized and flexible. Anyway, here’s the trouble I’m running into…

I need to get the custom capability associated with a post, without considering the current user’s capabilities.

So say I’ve got a post that is set to “Require Level #1 (or higher)” requiring the custom capability “music”. I want to get “music”…the custom capability associated with the post…to use in some code for a custom WordPress single post template.

Here’s a few snippets of what I’ve been trying…

$array = is_post_protected_by_s2member($postid);
print_r($array); // Print entire array

The above yields:
Array ( [s2member_level_req] => 1 )

I was hoping there would be at least two items in the array, not only the level but the ccap as well.

This works to get the Level associated with the post:

print_r($array[s2member_level_req]);

But this does not return the custom capability for the post:

print_r($array[s2member_ccap_req]);

Am I on the right track? Is this possible? Please help!

List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Monday Oct 7th, 2013 at 5:18 pm #60210
Moderator

Can you try this?

if (is_array ($ccaps_req = get_post_meta ($post_id, "s2member_ccaps_req", true)) && !empty ($ccaps_req)) {
	print_r($ccaps_req);
}

If you’re doing your check within The Loop, you can replace $post_id with get_the_ID(). See get_post_meta() on the WordPress Codex for more info.

Viewing 1 replies (of 1 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.