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.

Need to restrict Pages for members

Home Forums Community Forum Need to restrict Pages for members

This topic contains 20 replies, has 2 voices. Last updated by  Cristián Lávaque 4 years, 8 months ago.

Topic Author Topic
Posted: Tuesday Apr 24th, 2012 at 8:19 pm #11783

I’ve read through all the restrictions info, but am confused. Code makes me very dizzy.

I have various video courses that a person will purchase independently. If they purchase Course 2 (which is my Level 2), I don’t want them to be able to watch Course 3, etc. If a person is a VIP member (my Level 1), they should have access to everything. If a person is Level 0 (my faculty only, not other free subscribers), they will have access to everything.

How do I set this up? Do I just place this shortcode on the affected page?

[s2If current_user_is(s2member_level2) OR current_user_is(s2member_level1) OR current_user_is(s2member_level0)] Does this go on the actual page at the top?
is this all my page content here?

[/s2If] does this go at the bottom of the affected page after my content?

Do I need to put something in the sidebar box under Custom Capabilities to make this work?

It would help a lot if I could see an actual page with the code placed.

Thanks.

  • This topic was modified 4 years, 8 months ago by  Peggy Duncan.
  • This topic was modified 4 years, 8 months ago by  Peggy Duncan.

List Of Topic Replies

Viewing 20 replies - 1 through 20 (of 20 total)
Author Replies
Author Replies
Posted: Wednesday Apr 25th, 2012 at 5:58 am #11820

Well, levels give incremental access, so the higher level gives access to content at that level and all level below it.

Then the one with access to everything should be the highest one. Level 0 would not have any premium access, since it’s the default for free users (free registration or demotion after end of paid access).

Now, you have two courses, 2 and 3, which seem to be separate. One with course 2 doesn’t get 3, and vice versa, right? In that case, if using Levels to protect those courses, the higher level will get access to the lower one and it wouldn’t work for you.

It’d probably be better to use custom capabilities for courses 2 and 3, but then this would exclude the full access for the higher level. You’d still need to use conditionals.

[hilite pre_code]
[[s2If current_user_can(access_s2member_course2) OR current_user_can(access_s2member_everything)]
Show if user has access to everything or course 2.
[/s2If]]
[/hilite]

[hilite path]Dashboard -› s2Member® -› API / Scripting -› Simple/Shortcode Conditionals[/hilite]
[hilite path]Dashboard -› s2Member® -› API / Scripting -› Custom Capabilities[/hilite]
Video » s2Member (Custom Capabilities)

I hope that helps.

Posted: Wednesday Apr 25th, 2012 at 10:15 am #11833

Unfortunately, this hasn’t helped me. I’ll go in and make the changes to my high level and 0 levels and come back here for what I hope will be a clear enough explanation that I can make this work.

Posted: Wednesday Apr 25th, 2012 at 9:08 pm #11877

s2Member doesn’t currently support Level restriction for independent access, which is what the custom capabilities are for, and it doesn’t support independent access with custom capabilities combined with incremental access as Level does. And that’s what you want to set up: separate courses with one access level that gives access to all. We’re working on improving this soon so it’s possible in a simpler way.

For now, if you use levels for your courses 2 and 3, then you’ll have this situation:

Let’s say course 2 is at level 2 and course 3 at level 3. Then the user with level 2 will have access to course 2, but course 3 will be above his access. The user at level 3, though, will have access to course 3 and also course 2, because course 2 is protected at level 2, which is still an access he has.

You can do a couple of things in this case:

Use conditionals to determine when to show the content of the course. In that case, even if the user can load the page, the content will or won’t be there based on your conditional.

Read example 3 in the Shortcode Conditionals documentation for conditions that match an exact level, please. [hilite path]Dashboard -› s2Member® -› API / Scripting -› Simple/Shortcode Conditionals -> Example 3[/hilite]

The conditional using custom capabilities is what I explained in my previous reply.

The other thing you could do, instead of using the conditionals, is edit the s2Member role you’re selling the users so they don’t have access to every level below theirs. For this you’d use a plugin like User Role Editor. http://wordpress.org/extend/plugins/user-role-editor/

You could have sell s2Member Level 3 for full access and leave that role untouched, so it’ll have access to content at Level 3 and below. But then have a couple lower roles, s2Member Levels 1 and 2 for courses 2 and 3 respectively. Edit each of those s2Member role to remove access to the other levels below it, then each user will have access just to content at its level.

If you need more levels you can add more following the instructions here: [hilite path]Dashboard -› s2Member® -› General Options -› Membership Levels/Labels[/hilite]

Editing the user roles is a customization, and s2Member doesn’t behave that way by default, but it shouldn’t be too hard to figure out. Or just use conditionals as explained above and the documentation.

I hope that helps. :)

Posted: Thursday Apr 26th, 2012 at 1:51 am #11899

Thanks, Cristian! The User Role plugin is my kind of easy. I’ll have to add more levels as I add more courses.

Is there a test mode the admin can get into to check all functionality? Otherwise, I’m thinking I’ll set up a temporary level to test.

I’m doing Google Plus hangouts on Monday nights with people who are non-programmers building their own membership sites. We all agree that s2member is the way to go. I appreciate the thoroughness of the program. I knew right away that it was well thought-out. And the videos help so much too.

Posted: Thursday Apr 26th, 2012 at 3:51 am #11908

Thanks so much for the kudos, Peggy, you’re very nice. We’re glad you like s2Member and we’ll keep working to make it even better. :)

About adding more levels, if that’s what you plan to do, then it may be best to set the “all access” level as high as you can, so the new levels are all below it and you don’t need to move users with that access to a new higher level soon.

Posted: Thursday Apr 26th, 2012 at 4:35 am #11915

Where do I change “all access”?

I went into my wp-config.php file and added the line of text to add more levels. Site when white!! My Web host restored just the .php file, and I have the site back. Any idea what I did wrong?

Posted: Thursday Apr 26th, 2012 at 4:37 am #11916

Re-reading your last comment. On setting the highest level, you mean making my VIP level, for example, something like Level 50…I get it…I think.

Posted: Thursday Apr 26th, 2012 at 5:02 am #11919

Yeah, the one you called VIP. Sorry, I should have checked back to see what you had named it when I referred to it.

About the site going blank, you probably had a PHP syntax error in the code, or left a space or new line outside the PHP tags. It’s a good idea to make a copy of the file before editing it, so you can put it back the way it was quickly if needed.

I hope that helps. :)

Posted: Thursday Apr 26th, 2012 at 3:32 pm #11985

Cristian, Every time I add the line of text to my .php file and save, it ends up looking like this. And site page is white again. Do you have any idea about this? Does increasing the number of levels affect the memory WordPress needs?

<?php
define("MEMBERSHIP_LEVELS", 99);/** * The base configurations of the WordPress. * *

  • This reply was modified 4 years, 8 months ago by  Cristián Lávaque. Reason: Remove all the info
Posted: Friday Apr 27th, 2012 at 5:25 am #12030

Peggy, I removed the info you posted from your file. It contained login and other private info that shouldn’t be public. I saw this after a few hours of you posting it, so I recommend you change those values as soon as possible to avoid a security problem.

Once you’ve updated all the login info, could you send it to me privately using the contact form so I take a look at the problem? s2Member® » Private Contact Form

Thanks!

Posted: Friday Apr 27th, 2012 at 10:36 am #12050

Done. All private info changed. Thank you!

Posted: Friday Apr 27th, 2012 at 3:04 pm #12073

Good. :)

Posted: Friday Apr 27th, 2012 at 4:00 pm #12084

Cristian, I sent all info using contact form. Did you see?

Posted: Friday Apr 27th, 2012 at 4:05 pm #12085

Yes! I replied that right after my post here.

lol, just noticed I had forgotten to attach the file to my email. I sent it now. :)

Posted: Friday Apr 27th, 2012 at 5:16 pm #12094

Haven’t received anything.

Posted: Friday Apr 27th, 2012 at 5:45 pm #12096

Funny. I replied to the training email address you emailed me from. Maybe it went to your spam folder?

Posted: Friday Apr 27th, 2012 at 6:42 pm #12100

Nothing in Junk folder. Try different address, pscpress @ gmail.com

Posted: Friday Apr 27th, 2012 at 7:22 pm #12101

OK. Sent.

Posted: Saturday Apr 28th, 2012 at 2:21 am #12119

Got it. It worked! Thank you!

Posted: Saturday Apr 28th, 2012 at 2:35 am #12121

Great! Thanks for the update. :)

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