Page 1 of 1

REstrict Links inside Blog Posts?

PostPosted: May 14th, 2011, 3:02 am
by starme
Is there any way wherein only premium members can view the links inside the blog posts?

Thanks!

Re: REstrict Links inside Blog Posts?

PostPosted: May 14th, 2011, 7:00 am
by rossagrant
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!

Re: REstrict Links inside Blog Posts?

PostPosted: May 15th, 2011, 6:54 pm
by moses5407
This looks great..but WHERE do I use these shortcodes? Each page and/or post .. or at some higher level? or both?

Re: REstrict Links inside Blog Posts?

PostPosted: May 15th, 2011, 7:12 pm
by rossagrant
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!

Re: REstrict Links inside Blog Posts?

PostPosted: May 15th, 2011, 8:56 pm
by moses5407
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..

Re: REstrict Links inside Blog Posts?

PostPosted: May 16th, 2011, 12:01 am
by moses5407
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.

Re: REstrict Links inside Blog Posts?

PostPosted: May 16th, 2011, 1:31 am
by Cristián Lávaque
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/

Re: REstrict Links inside Blog Posts?

PostPosted: May 16th, 2011, 4:06 pm
by moses5407
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.

Re: REstrict Links inside Blog Posts?

PostPosted: May 16th, 2011, 5:33 pm
by Cristián Lávaque
Simple conditionals are shortcodes. Advanced and andvanced query conditionals are PHP, try them in the templates.