Page 1 of 1

Automating a public excerpt

PostPosted: October 27th, 2010, 2:28 pm
by sugeneris
My client wants to protect entry pages, but for SEO etc. purposes wants to allow the post excerpt to appear publicly on the pages, with a prompt to login/register. So, when an unauthorized visitor tries to view the page, they'll see roughly:

Introductory paragraph or whatever.
To see the rest of this post, please register or login.


We've found this prior forum post, but it's regarding specifying an excerpt manually every time, which I'd like to avoid.

Now, as far as I can tell, what I need is the Advanced Query Conditionals functions, and the examples in there seem obvious enough. I was thinking example #2, except instead of the continue statement, I'd actually echo out some content. But I've experimented a little, and no matter what I do, the page simply kicks me to the subscription options page rather than showing the sample content. Is there something I need to additionally disable, or am I going about this the entirely wrong way?

Re: Automating a public excerpt

PostPosted: October 29th, 2010, 4:00 am
by Jason Caldwell
Thanks for the great question.
My client wants to protect entry pages, but for SEO etc. purposes wants to allow the post excerpt to appear publicly on the pages, with a prompt to login/register. So, when an unauthorized visitor tries to view the page ...

Since I posted that, Simple Conditionals were released in recent versions of s2Member, and that's the way you'll probably want to go. The problem I think you're seeing, is caused by the way you want "Excerpts" to work. "Excerpts" are normally displayed in an Archive View of some sort.

Documentation: Protecting individual Posts or Pages, ONLY protects the Permalinks for those Posts. It is still possible for Excerpts of protected content to be seen in search results generated by WordPress®, feeds, and Archive views; such as your Home Page, inside a Category listing, or through other queries formulated by your theme. This is the intended functionality. Excerpts are a great way to "tease" public visitors. In other words, public visitors may have access to excerpts introduced by your theme, but any attempt to view the full Post ( i.e. the Permalink ) will result in an automatic redirect to your Membership Options Page; requiring registration. All of that being said, if you would like to protect many Posts at once ( including Archive views ), you can use Category Level Restrictions, Tag Level Restrictions, or have a look at s2Member's options for "Alternative View Protection", which deals with search results, as well as feeds.

What's important to realize here, is that s2Member will ALWAYS protect the Permalink ( i.e. the full content view ) for the Posts/Pages you protect in the General Options panel, or through the Meta Box on the Post editing form. Because, "Excerpts" should be displayed in an "Archive View" of some kind. If you want to integrate another form of more customized protection, you can use Conditionals.

So here is my recommendation:

Un-protect everything that you've configured in your s2Member General Options Panel, and instead, create your own protections using Simple or Advanced Conditionals, like this:

Code: Select all
Here is the beginning of my Post for everyone to see ...

[s2If current_user_cannot(access_s2member_level1)]
    To see the rest of this post, please register or login.
[/s2If]


[s2If current_user_can(access_s2member_level1)]
    ... here is the rest of my content.
[/s2If]
So here you are handling things in a much more advanced (custom) way. You can just forget about s2Member's protections in the General Options panel in this case.

Re: Automating a public excerpt

PostPosted: October 30th, 2010, 5:17 pm
by sugeneris
Okay, that was the bit I didn't understand. I'd thought the conditionals worked in concert with the various toggles in the general options tab. Instead it seems that what I need to do is turn those basic protections off and just build the protection rules directly into my template files, correct?

(Quick and dirty testing with the example snippet I mentioned above seems to agree, but just confirming.)

Re: Automating a public excerpt

PostPosted: November 4th, 2010, 9:36 am
by Jason Caldwell
sugeneris wrote:Okay, that was the bit I didn't understand. I'd thought the conditionals worked in concert with the various toggles in the general options tab. Instead it seems that what I need to do is turn those basic protections off and just build the protection rules directly into my template files, correct?

(Quick and dirty testing with the example snippet I mentioned above seems to agree, but just confirming.)

Yes, you are correct. Thanks for the reply back.