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™

Protect part of a post or page

s2Member Plugin. A Membership plugin for WordPress®.

Protect part of a post or page

Postby jlawlor » May 8th, 2010, 7:55 pm

I am looking to protect part of a post or page but can't find any docs that address this.

In Wishlist member content can be restricted by inserting <<more>>
It would be great to have the ability to insert test that is only for a specific user level or above.
ie. [user3] some text for viewing user level 3 and 4[/user]

Have I missed something in the docs?
User avatar
jlawlor
Registered User
Registered User
 
Posts: 1
Joined: May 8, 2010

Re: Protect part of a post or page

Postby PerryM » May 11th, 2010, 7:58 am

I've asked the same question and I believe there is a "Geekie" way of doing it but a new plug-in was just released http://wordpress.org/extend/plugins/restrictedarea/ which does a super job.

You also need a plug-in http://wordpress.org/extend/plugins/capsman/ so you can change the Level from 0 to 1,2,3 or 4 for the other plug-in.

Hope this helps
User avatar
PerryM
Registered User
Registered User
 
Posts: 10
Joined: May 7, 2010

Re: Protect part of a post or page

Postby Jason Caldwell » May 13th, 2010, 12:56 am

Hi John. Thanks for your inquiry. Check out this section:
s2Member -> API Scripting -> Advanced Conditionals.
There are 5 different code samples that can be used to build Conditionals similar to WishList.
advanced-conditionals.jpg
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Protect part of a post or page

Postby weblev » May 26th, 2010, 2:37 pm

Where and how do I install this code?
User avatar
weblev
Registered User
Registered User
 
Posts: 4
Joined: May 21, 2010

Re: Protect part of a post or page

Postby HTMwebrat » May 26th, 2010, 4:04 pm

You need to have Exec-PHP installed, then make sure you use ONLY the HTML editor on posts and pages, as the Visual editor will destroy the code. With this, you can put it directly into posts and pages.

Here's an example from my test "welcome" page

Code: Select all
<?php if (S2MEMBER_CURRENT_USER_IS_LOGGED_IN){ ?><!-- checks to see if they're logged in at all, if they are, we show -->
Welcome, <?php echo S2MEMBER_CURRENT_USER_DISPLAY_NAME; ?>! <br>
You are currently a "<b><?php if (is_user_logged_in() && current_user_can("access_s2member_level1")){ ?><?php echo S2MEMBER_CURRENT_USER_ACCESS_LABEL; ?><?php } else { ?>  Free Member<?php } ?> </b>", and have been for <b><?php echo S2MEMBER_CURRENT_USER_REGISTRATION_DAYS; ?></b> days.

<!-- this doublechecks to make sure they're logged in (not sure why I did that) and makes sure they're of a minimum level, then tells them their level label (which you specify in the options) and tells them how long, overall, that they've been a member -->
<br style="clear:all;">

<i>Modify Your User Information</i>-<br>
<iframe src="<?php echo S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL; ?>" scrolling="auto" style="width:60%; height:325px; margin:auto; border:1px solid #666666;"></iframe>
<!-- this embeds the box where the user can modify their info -->
<?php } <!-- end this statement -->
else { ?> <!-- else, begin where we show something for users who are not logged in -->

You are not logged in. Please <A HREF="<?php echo S2MEMBER_LOGIN_PAGE_URL; ?>">click here to log in and proceed</A>!
<br><br>
Not a member? <a href="<?php echo S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL; ?>">Click here to sign up today!</A>
<?php  } ?> <!-- end the first if/else statement -->


This code is on a private test page and may be a bit outdated, since my site's plans have changed and we're holding off on a members area for a bit. The last bit isn't needed if you set "Allow Free Subscribers Access To This Page? " to No, I believe.
User avatar
HTMwebrat
Registered User
Registered User
 
Posts: 23
Joined: May 5, 2010
Location: Gettysburg, PA, USA

Re: Protect part of a post or page

Postby weblev » June 3rd, 2010, 1:13 pm

Thanks!
User avatar
weblev
Registered User
Registered User
 
Posts: 4
Joined: May 21, 2010

Re: Protect part of a post or page

Postby drbyte » June 3rd, 2010, 2:45 pm

jlawlor wrote:I am looking to protect part of a post or page but can't find any docs that address this.

In Wishlist member content can be restricted by inserting <<more>>
It would be great to have the ability to insert test that is only for a specific user level or above.
ie. [user3] some text for viewing user level 3 and 4[/user]

Have I missed something in the docs?



Hi Jlawlor

I'd use

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.(can be link to your loginout, just add [code]<?php wp_loginout(); ?>[/code]
<?php } ?>


You can use a dynamic loginout script so they wont leave the page they are in.

It's the easiest way to protect your content regardless of any level.

If you are worrying about loosing some of your site ranking with Google or any other search engine, I really recommend using the above code. I also noticed decrease in site searches and the amount of new visitors to my site when using the Cat/Post/Page Access Restrictions.

Hope that helps

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

Re: Protect part of a post or page

Postby Walton » January 24th, 2011, 11:16 pm

Anyway to set up conditionals for partial access to specific posts and pages?

I want to protect posts with Specific Post/Page Access and when users go to that post, they have access to part of the post--i.e. where I say that this is paid content and put my Paypal button. Then after they pay, they have full access.

Didn't see a conditional for specific post/page access in the API section.

EDIT: Would
Code: Select all
if(!is_permitted_by_s2member())

do it?
User avatar
Walton
Registered User
Registered User
 
Posts: 6
Joined: January 24, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Bing [Bot] and 3 guests

cron