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.

is_permitted_by_s2member not working

Home Forums Community Forum is_permitted_by_s2member not working

This topic contains 5 replies, has 4 voices. Last updated by  Eduan 4 years, 1 month ago.

Topic Author Topic
Posted: Tuesday Dec 4th, 2012 at 5:30 pm #33481
Peter R
Username: PeterRK

2 Questions about the way S2Member treats page level access restrictions:

#1

On my install S2Member appears to behave differently when I restrict access to a page by setting a specific level from the post editing screen (through the metabox) or through s2member>restrictions options>page access restrictions.

When I set the restrictions via the s2member settings screen things work as intended, but if I set the restrictions via the meta box, the conditional is_permitted_by_s2member( $post_id ) doesn’t return false when it is supposed to. This is remedied when I manually plug in the id through s2member>restrictions options>page access restrictions.

Is that intended behavior? I would expect any adjustments made to page access from the post/page editing screen to show up at s2member>restrictions options>page access restrictions.

#2

When restricting a page based on a specific custom capability, will is_permitted_by_s2member( $post_id ) check for that? Unless something on my setup is interfering, it doesn’t seem to. If this is intended, is there another alternative conditional that will take post_id as a parameter and check for the current user’s access privileges?

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Tuesday Dec 4th, 2012 at 6:54 pm #33496
Eduan
Username: Eduan
Moderator

Hello Peter,

I’m afraid the answer to these only Jason can provide. I will contact him so that he may provide the answer. Contacted him, he will answer as soon as he can. :)

– Eduan

Posted: Wednesday Dec 5th, 2012 at 5:24 am #33528
Staff Member

Thanks for the heads up on this thread.

#1

On my install S2Member appears to behave differently when I restrict access to a page by setting a specific level from the post editing screen (through the metabox) or through s2member>restrictions options>page access restrictions.

When I set the restrictions via the s2member settings screen things work as intended, but if I set the restrictions via the meta box, the conditional is_permitted_by_s2member( $post_id ) doesn’t return false when it is supposed to. This is remedied when I manually plug in the id through s2member>restrictions options>page access restrictions.

Is that intended behavior? I would expect any adjustments made to page access from the post/page editing screen to show up at s2member>restrictions options>page access restrictions.

No, that would indicate to me there is either some confusion about how the API function works, or that there is a deeper issue somewhere in your installation somehow. Restrictions set in the Post/Page editing station (with respect to Level-based Restrictions), are simply updating the options that you see under this section of your Dashboard. Nothing more.

Dashboard -› s2Member® -› Restriction Options -› Post (or Page) Access Restrictions

Is this continues to be a problem, please submit a list of specific instructions on how we can reproduce this in a default WP installation, and we’ll take a closer look for you. I’m not currently aware of any issues in this regard. I was unable to reproduce it with the details we have so far.

#2

When restricting a page based on a specific custom capability, will is_permitted_by_s2member( $post_id ) check for that? Unless something on my setup is interfering, it doesn’t seem to. If this is intended, is there another alternative conditional that will take post_id as a parameter and check for the current user’s access privileges?

Yes, if you’ve used the Post/Page editing station to add a list of one or more Custom Capabilities required to gain access to certain Posts or Pages, the is_permitted_by_s2member() function will consider those Custom Capabilities as well, before it returns TRUE or FALSE. So for instance, if a Post requires Level #2 access, and it also requires Custom Capability music, the is_permitted_by_s2member() function will return FALSE for someone at Level #2, who does NOT also have the Custom Capability music.


Here are some things I would take a look at:

Have you configured s2Member with a Membership Options Page yet? If not, this is the problem.
See: Dashboard -› s2Member® -› General Options -› Membership Options Page

Are you logged in as an Administrator when testing? If so, this is the problem. Administrators have full access to everything, regardless of your configuration of Level Restrictions or Custom Capabilities. You’ll want to log out of your Administrator account and into an account that will reflect the proper permission level.

Are you passing an ID into this API function?

<?php
if(is_permitted_by_s2member(123))
	echo 'Yes';
else echo 'Nope!';
?>

Reference article in Codex: http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_is_permitted_by_s2member()


Please let us know if problem persist. Thanks!

Posted: Wednesday Dec 5th, 2012 at 10:33 am #33570
Peter R
Username: PeterRK

Thanks Jason and Eduan!

After the clarification and realizing that the functions indeed should be working as advertised I spotted the problem. I was passing the wrong ID’s in my custom navigation menu filter and is_permitted_by_s2member was working after correcting that. D’oh. I was using the nav item id’s thinking they were the page ids, i.e. the difference between $item->ID and $item->object_id. I could have spotted that sooner, stupid of me.

Anyway, case closed!

Posted: Wednesday Dec 5th, 2012 at 2:12 pm #33589
Bruce
Username: Bruce
Staff Member

Hi Peter,

Glad to hear you figured out the problem.

Posted: Wednesday Dec 5th, 2012 at 10:34 pm #33657
Eduan
Username: Eduan
Moderator

I’m glad you found the problem Peter. :)

Viewing 5 replies - 1 through 5 (of 5 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.