Page 1 of 1

Custom Capabilities not working?

PostPosted: September 17th, 2011, 11:11 am
by kiwis
Not sure if anyone has encountered this... and it only happened very recently so I'm sure I broke it but I can't seem to find where. Maybe there's another plug-in causing it but I've checked the known conflicts and still can't find anything. Please help and thank you in advance!

Problem:
All of the custom capabilities on the site is all of a sudden broken/not firing.

Symptoms:
Standard capabilities check is still working. ie.
Code: Select all
<?php if (current_user_can("access_s2member_level1")){ ?>
if level 1... stuff...
<?php } ?>


Any of the custom capabilities are not working i.e. I have a user set up with level 1 and custom capabilities 10white. with the code below:
Code: Select all
<?php if (current_user_can("access_s2member_level1")){ ?>
<?php if (current_user_can("access_s2member_ccap_10white")){ ?>
user can access 10 white labels.. display some stuff.
<?php } ?>
<?php if (current_user_can("access_s2member_ccap_01red")){ ?>
user can access 1 red labels.. display some stuff.
<?php } ?>
<?php } else { ?>
No access to page at all
<?php } ?>


When the user loads the page this is what shows:
Code: Select all
user can access 10 white labels.. display some stuff.
user can access 1 red labels.. display some stuff.


So basically the check for s2Member level 1 passes.. but somehow both capabilities are returning true. I've even just done a simple return statement to check this and yes, both IF statements are returning true. I've checked that the test user is only set up with CC 10white. In fact, if I remove all of the user's CC, the page returns the same thing.

What could possibly be wrong? Any hints/thoughts would be great! Thanks!

Re: Custom Capabilities not working?

PostPosted: September 17th, 2011, 12:25 pm
by kiwis
OK. Now I feel REALLY retarded.
I answered my own question.

As it turns out Admin users have access to view everything on the page regardless of custom restrictions. >.< doh!

Re: Custom Capabilities not working?

PostPosted: September 26th, 2011, 1:47 am
by Cristián Lávaque
No problem, it's happened to others too. :)

Let us know if you have more questions.