Page 1 of 1

API Scripting for "Teaser"

PostPosted: July 18th, 2010, 9:15 pm
by SteveS
Hi, I am new to writing on this forum, however I've read through it for a few weeks now.

First of, want to say s2Member is an amazing plugin... you guys have done a lot for the community!

I have a question that is related to this topic (http://www.primothemes.com/forums/viewtopic.php?f=4&t=103&p=500&hilit=post+teaser#p500), however I can't seem to figure it out exactly.

I've looked at the code samples and they are exactly what I need, however where do I add them in so that I only show a snippet of my post and they have to register/login to see the rest?

I have Exec-PHP, but don't know exactly how to use it in conjunction with my post.

Here is an example of what I'm trying to do:

When a customer selects http://www.unbreakablewarrior.com, and navigates to the "Blog" section, I want them to only be able to see the following:
"Unbreakable Warrior has recently released a press release:"

Then they would have to login to be able to view the link.

How do I place the PHP code?

Re: API Scripting for "Teaser"

PostPosted: July 22nd, 2010, 6:22 am
by Jason Caldwell
You would need something like this inside the HTML tab of your Post /or Page.
Code: Select all
This is my article.. here is some text...

<?php if (current_user_can("access_s2member_level1")){ ?>

    Here is the rest of my text, available to Members only!

<?php } else { ?>

    Please pay me 1 million dollars to read the rest :-)
    <a href="<?php echo S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL; ?>">signup now</a>

<?php } ?>

The else condition is optional.
I included it only to improve the example.

Here is another example that ONLY checks if they're a Member.
Code: Select all
This is my article.. here is some text...

<?php if (current_user_can("access_s2member_level1")){ ?>

    Here is the rest of my text, available to Members only!

<?php } ?>

For the benefit of other readers. In order to use s2Member's Advanced Conditionals, you will need to install the Exec-PHP plugin for WordPress. Further documentation on Advanced Conditionals, can be found inside your WP Dashboard, under: s2Member -> API Scripting -> Advanced Conditionals