latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Query Content Level

Home Forums Community Forum Query Content Level

This topic contains 3 replies, has 2 voices. Last updated by  Trevor Wilcox 4 years, 5 months ago.

Topic Author Topic
Posted: Wednesday Aug 8th, 2012 at 11:15 pm #21584

Hi there, I’m trying to follow along with the scripting examples of conditionals, and maybe I’m overlooking something, but can’t find the answer to what I’m trying to achieve.

I would like to query the permission level of specific posts, and display it in the call-to-action following an excerpt.

For example, say I have a post designated as Level 3, and a Level 1 subscriber attempts to access it.

The structure might look something like:

TITLE
Excerpt […]

***This article is classified as Level 3 content. In order to access this article, please upgrade.***

Obviously I can’t just write Level 3 into the conditionals like this, because it would then be applied to all levels of content, even those of a lower classification; the level will change according to the specific post. So there must be a way to query it.

Is this possible?

Thanks!

  • This topic was modified 4 years, 5 months ago by  Trevor Wilcox.

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Thursday Aug 9th, 2012 at 9:31 am #21626
Eduan
Username: Eduan
Moderator

Hello Trevor,

You would use simple conditionals for this, you can find an article about conditionals here:
Knowledge Base » s2Member® Conditionals

Pretty sure it also tells you how to make it level specific. It would be:

[s2If current_user_is(s2member_level1)]
    Content exclusively for members level 1. Maybe something saying "Upgrade now!".
[/s2If]

Hope this helps. :)

Posted: Friday Aug 10th, 2012 at 2:09 am #21674

Thanks Eduan. But that’s not quite what I meant. Your example returns a specific string based on the user’s subscription level. For the purpose of the string, I need to make it relative to the content instead of the user.

Let me paint a scenario.

There are two posts – one classified as Level 2, and one classified as Level 3.

I put this code in to my template for everyone who can access Level 1 or above.

<?php if (current_user_can("access_s2member_level1")){ ?>
    
	This content is classified as Level 3.
	
	<?php } else { ?>

    Some public content.
<?php } ?> 

This would also be applied to the Level 2 post, telling people it’s classified as Level 3. Which is wrong. Therefore there needs to be some mechanism that dynamically grabs which level the content is (kind of like a “mail merge field”), something like this (somehow):

<?php if (current_user_can("access_s2member_level1")){ ?>
    
	This content is classified as <<POST LEVEL>>.
	
	<?php } else { ?>

    Some public content.
<?php } ?> 

Any ideas?

Posted: Friday Aug 10th, 2012 at 2:57 am #21675

Alex’s solution here gets me pretty close to what I need:

http://www.s2member.com/forums/topic/show-them-what-level-they-need/

Viewing 3 replies - 1 through 3 (of 3 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.