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™

REstrict Links inside Blog Posts?

s2Member Plugin. A Membership plugin for WordPress®.

REstrict Links inside Blog Posts?

Postby starme » May 14th, 2011, 3:02 am

Is there any way wherein only premium members can view the links inside the blog posts?

Thanks!
User avatar
starme
Registered User
Registered User
 
Posts: 12
Joined: March 29, 2011

Re: REstrict Links inside Blog Posts?

Postby rossagrant » May 14th, 2011, 7:00 am

Super easy!

Navigate your way to the menu inside the dashboard S2Member--->API/Scripting--->Using Simple Conditionals.

It will show you how you can wrap ANYTHING in a shortcode which will only give users who are of a certain level access to it.

To any other members they simply won't see it, or you can put some other text inbetween shortcodes for the free members to see which says something like, 'To View This Link, Upgrade Your Subscription!' etc.

I use them all the time and Jason is looking at implementing these codes by means of a button in the visual editor for easy implementation in future versions.

Hope that helps!
User avatar
rossagrant
Experienced User
Experienced User
 
Posts: 127
Joined: May 5, 2010

Re: REstrict Links inside Blog Posts?

Postby moses5407 » May 15th, 2011, 6:54 pm

This looks great..but WHERE do I use these shortcodes? Each page and/or post .. or at some higher level? or both?
User avatar
moses5407
Registered User
Registered User
 
Posts: 17
Joined: March 30, 2011

Re: REstrict Links inside Blog Posts?

Postby rossagrant » May 15th, 2011, 7:12 pm

Use them wherever you like, just wrap the content in the shortcode in a post or page.

So If I wanted to restrict a link, I might use 3 'If' statements like this:

Code: Select all
[s2If !is_user_logged_in()]To access this link please <a href="http://www.put your link to your premium registration page here">sign up for  a Premium membership</a>.[/s2If]

[s2If current_user_is(s2member_level0)]To access this link please <a href="http://www.put your link to your premium registration page here">upgrade to  a Premium membership</a>.[/s2If]

[s2If current_user_can(access_s2member_level1)]PUT YOUR LINK HERE[/s2If]


So above we have 3 options.

1.) The first is displayed to visitors who are not logged in and they are told to SIGN UP for a PREMIUM membership in order to view the link.

2.) This second option is only displayed to members WHO ARE LOGGED in but have a FREE account at level 0. They are told to UPGRADE in order to see the link.

3.) This link is displayed to LEVEL 1 or PREMIUM members and they just see the link.

So you have now configured what each person will see on the page. You can change the conditionals to include members of different levels or as you see fit.

Hope that helps, it's a great feature that EVERYONE should use to get the most out of this plugin!
Last edited by Cristián Lávaque on May 16th, 2011, 1:29 am, edited 1 time in total.
Reason: Improve code readability. http://www.primothemes.com/forums/viewtopic.php?f=36&t=2780
User avatar
rossagrant
Experienced User
Experienced User
 
Posts: 127
Joined: May 5, 2010

Re: REstrict Links inside Blog Posts?

Postby moses5407 » May 15th, 2011, 8:56 pm

Cool! and thanks!

is there a higher level method that would apply to links on all pages versus in single pages or posts?
Might come in handy..site-maintenance-wise..
User avatar
moses5407
Registered User
Registered User
 
Posts: 17
Joined: March 30, 2011

Re: REstrict Links inside Blog Posts?

Postby moses5407 » May 16th, 2011, 12:01 am

oops..nevermind. I had a fundamental misunderstanding. This is instruction for use of shortcodes within post or page content. I am looking for a way to use shortcodes within a page template to restrict certain content generated by that template. If anyone knows of a link to such info..it's appreciated.
User avatar
moses5407
Registered User
Registered User
 
Posts: 17
Joined: March 30, 2011

Re: REstrict Links inside Blog Posts?

Postby Cristián Lávaque » May 16th, 2011, 1:31 am

Then you'd used advanced conditionals. ;)

WP Admin -> s2Member -> API / Scripting -> Using Advanced Conditionals
WP Admin -> s2Member -> API / Scripting -> Advanced Query Conditionals

http://www.s2member.com/api-scripting-overview-video/
http://www.s2member.com/advanced-conditionals-video/
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: REstrict Links inside Blog Posts?

Postby moses5407 » May 16th, 2011, 4:06 pm

Thanks..but these address using shortcodes in individual pages, posts, and at the theme level via functions.php ... not the ability to use shortcodes within a template as far as I can tell.
User avatar
moses5407
Registered User
Registered User
 
Posts: 17
Joined: March 30, 2011

Re: REstrict Links inside Blog Posts?

Postby Cristián Lávaque » May 16th, 2011, 5:33 pm

Simple conditionals are shortcodes. Advanced and andvanced query conditionals are PHP, try them in the templates.
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


Return to s2Member Plugin

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 1 guest

cron