PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Admin Custom Capabilities

s2Member Plugin. A Membership plugin for WordPress®.

Admin Custom Capabilities

Postby drbyte » July 1st, 2011, 8:07 am

Hi Guys

Not sure why the admin Custom Capabilities not responding....I tried all of them without any luck...ccaps, levels ..nothing works. They have the latest WP, S2m Free

admin not showing current_user_is for all 4 levels. When WP going to allow S.Admin for single WP Installation?!!

Thanks

Sam

Have a super nice 4th Guys...Stay Safe
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Admin Custom Capabilities

Postby Cristián Lávaque » July 1st, 2011, 8:16 pm

Admin needs ccaps to access ccap restricted content, it's not like with Levels where the admin can view any level.

Admin is not other levels, you have to use current_user_can to check the capability instead of the role.

I hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Admin Custom Capabilities

Postby drbyte » July 1st, 2011, 11:11 pm

Thanks Cris

The admin can't view any level using this:

Code: Select all
<?php if (current_user_can("access_s2member_level1")){ ?>
    Some content for Members who are logged in with an s2Member Level >= 1.
<?php } else { ?>
    Some public content.
<?php } ?>


Now if it's set to this, no problem

Code: Select all
<?php if(is_user_logged_in()){ ?>
    Content for anyone that is logged in, regardless of their Membership Level.
<?php } else { ?>
    Some public content.
<?php } ?>


If you change it using current_user_can still no admin access to different levels beside level 0

I know I am missing something in here...

* A Member with Level 4 access, will also be able to access Levels 0, 1, 2 & 3.
* A Member with Level 3 access, will also be able to access Levels 0, 1 & 2.
* A Member with Level 2 access, will also be able to access Levels 0 & 1.
* A Member with Level 1 access, will also be able to access Level 0.
* A Subscriber with Level 0 access, will ONLY be able to access Level 0.
* A public Visitor will have NO access to protected content.

Now, Level 4 role is basically higher than the administrator role when viewing restricted contents because the admin is not a level.

Would you please show how can we rewrite the code above for them to have access to different levels. Or if you have steps of doing so will be great. Thank you Cris

Would something like this work

Code: Select all
global $current_user;
get_currentuserinfo();
If($current_user->user_login != ‘admin‘)
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Admin Custom Capabilities

Postby Cristián Lávaque » July 2nd, 2011, 1:42 am

Hmm... The thing is that admin would never be restricted by a default installation of s2Member. Have you played with the capabilities using a plugin like User Role Editor? Maybe you touched something that removed from your admin role the access to s2Member protected content?

Could you test with a clean installation of WordPress and s2Member to check how this works for you there?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Admin Custom Capabilities

Postby drbyte » July 2nd, 2011, 1:53 am

Hi Cris

yes I did test it on a demo site. Nothing shows up when admin is logged in. Interesting!

Sam
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Admin Custom Capabilities

Postby drbyte » July 2nd, 2011, 1:56 am

Acutally I take it back...it's working with the short codes not PHP scripting

This works

Code: Select all
[s2If current_user_can(access_s2member_level1)]
    Some content for Members who are logged in with an s2Member Level >= 1.
[/s2If]

[s2If !current_user_can(access_s2member_level1)]
    Some public content.
[/s2If]


This does not work

Code: Select all
<?php if (current_user_can("access_s2member_level1")){ ?>
    Some content for Members who are logged in with an s2Member Level >= 1.
<?php } else { ?>
    Some public content.
<?php } ?>
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Admin Custom Capabilities

Postby Cristián Lávaque » July 2nd, 2011, 2:13 am

Thanks for testing it and reporting your findings! I'll email Jason about this.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Admin Custom Capabilities

Postby drbyte » July 2nd, 2011, 2:18 am

OK, something is wrong with this statement

Code: Select all
<?php if (current_user_is("s2member_level4")){ ?>
<?php } else if (current_user_is("s2member_level3")){ ?>
<?php } else if (current_user_is("s2member_level2")){ ?>
<?php } else if (current_user_is("s2member_level1")){ ?>
<?php } else if (current_user_is("s2member_level0")){ ?>
<?php } else { ?>
<?php } ?>


What would be the correct statement with the current_user_can Cris?

I can't seem to put it together....

Thanks
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Admin Custom Capabilities

Postby Cristián Lávaque » July 2nd, 2011, 2:33 am

That code will show different things to each specific role. The current_user_can check will work with the incremental access.

In your code above, a Level 2 user would only be true for the current_user_is("s2member_level2") condition, while he'd be true for these current_user_can ones:

current_user_can('access_s2member_level2')
current_user_can('access_s2member_level1')
current_user_can('access_s2member_level0')


Does that help?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Admin Custom Capabilities

Postby drbyte » July 2nd, 2011, 2:50 am

I understand what you mean Cris...thanks for the help

Have a nice Holiday

Sam
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 2 guests

cron