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.

Index page seems unprotected

Home Forums Community Forum Index page seems unprotected

This topic contains 11 replies, has 3 voices. Last updated by  Eduan 4 years, 6 months ago.

Topic Author Topic
Posted: Thursday Jul 5th, 2012 at 10:12 am #18391
Echomango
Username: echomango

I have just started configuring S2Member and want to offer hearty thanks for such a fantastic program. It is amazing what you have done. Kudos.

As I have started to play with things I noticed that as I post new posts (videos) they go to the index page of my site and when I logout and try to play them they play just fine. ugh. When I click the title of the post on the index page it goes to that particular page ie “mysite.com/?p=71” and when I visit that particular page the videos are protected. I am guessing that there is some switch someplace that I have not clicked…that protects content on the index page. Or maybe the standard is to make the membership option page your index page? http://mysite.com/

Any help for this newb would be very much appreciated.

thanks, echo

List Of Topic Replies

Viewing 11 replies - 1 through 11 (of 11 total)
Author Replies
Author Replies
Posted: Friday Jul 6th, 2012 at 11:10 pm #18511
CodeClips
Username: codeclips

If you want the “?p=71” post restricted, you should specify its restriction by editing that post and specify on the right side that has the box “S2Member ” and “Post Level Restriction?” then update the post.

Posted: Saturday Jul 7th, 2012 at 4:05 pm #18574
Echomango
Username: echomango

Thanks for your response CodeClips.info. I think that the “?p=71″ post is indeed protected when it is called with that tag on the url. The problem is that when I create any new post, the post is posted on the index page and when it is posted on the index page it is public and viewable to all even though I have set the restrictions on the post as level 1.

I am guessing that i could direct all posts to another page and that might solve the problem. I am also guessing that a better bet is that I am missing something very simple here and would love to know what it might be.

Thanks for any help you might have with this.

Echo

Posted: Saturday Jul 7th, 2012 at 9:34 pm #18583
CodeClips
Username: codeclips

Ok, I see your point now. If the post is called directly using mysite.com/?p=71 the post is protected. But if you go to your home page especially if the setting is to show the latest posts, that protected post is shown along with the other new posts as though it was not protected.

The solution to this is to edit your index.php to include the S2Member protection when listing the posts that may include the protected ones.

Here’s what you’ll do:

Add the following code before the “the Loop”:

<?php attach_s2member_query_filters();query_posts(''); ?>

For example, it will appear somewhat like this:

<?php if ( have_posts() ) : ?>

	<?php attach_s2member_query_filters();query_posts(''); ?>
	
	<?php /* Start the Loop */ ?>
	<?php while ( have_posts() ) : the_post(); ?>

This will filter all the posts, custom posts, or pages to be publicly shown. The protected posts, custom posts or pages are included is the user has access to the post, custom post, or page.

You can also add this code clip to other areas of your theme like the archive, blog, etc. that lists all the posts or pages on your site.

Posted: Sunday Jul 8th, 2012 at 5:21 pm #18627
Eduan
Username: Eduan
Moderator

Hello Tom,

I suggest you check the settings under Dashboard -› s2Member® -› Restriction Options -› Alternative View Protection.

Hope this helps. :)

Posted: Sunday Jul 8th, 2012 at 10:34 pm #18639
Echomango
Username: echomango

Thank you both for your help with this. I think that slowly I am starting to understand more about the program. The more I read the documentation the more I get it. ;>)

It seems that the intent of the program is to place a portion of the newest posts onto the index page as a teaser with a link back to the full post that can then be purchased. Great idea but it doesn’t work so hot with video content. I tried typing a couple of paragraphs in from of the link to the video but that didn’t seem to work. Instead I changed the page that new posts are sent and then was able to restrict access to that page. It’s not an elegant solution but it seems to work okay for now. I am guessing that the more I read the documentation the better off I will be.

Codeclips – Thanks for an excellent description of the problem. I opened up the index.php and the code was very simple and there was no reference to the loop you have referred to. Not sure where to go with that. Perhaps I was opening the wrong file?

Eduan – I played around a bit with the alternative view protection. Very interesting stuff but it didn’t seem to restrict the content on the index page It was then that I started realizing that I was remiss for not being more diligent in reading the documentation. So thanks for pointing me in that direction.

I would still be interested to know if there is a way to restrict the video to play back on the index page but have a shell there. I guess one way to do it would be to take a jpeg of the video in the player and have that jpg linked to the restricted file. That way the user would see a picture of the video in question and could also read a little text about what they might find but would have to click the ?p=71 link to see the actual video and if they were not a member they would be sent to the membership option page.

Posted: Monday Jul 9th, 2012 at 12:45 am #18642
CodeClips
Username: codeclips

@Tom Golden
Placing the code clip that I suggested depends on the theme that you are using. As an example, I’m using the TwentyEleven theme that came with the WordPress fresh install.

What theme are you using? If it’s a Genesis child theme then the approach would be much different.

Anyway, the sample that I gave filters the post from being included on the posts list.

Now if you want to show some sample intro into the post, you might use the [ s2If ] tag. For example:

The Mitsubishi Outlander is a crossover manufactured by Japanese automaker Mitsubishi Motors. It was originally known as the Mitsubishi Airtrek when it was introduced in Japan in 2001, and was based on the Mitsubishi ASX concept vehicle exhibited at the 2001 North American International Auto Show. The ASX (Active Sports Crossover) represented Mitsubishi’s approach to the industry wide XUV trend for retaining the all-season and off-road abilities offered by a high ground clearance and four-wheel drive, while still offering car-like levels of emissions, economy and size.

[s2If is_user_logged_in()]
--- restricted video here which appears only to the logged in users  ---------------
[/s2If]

[s2If !is_user_logged_in()]
---- sample embedded video here or JPEG image which appears to everyone who is not logged in -------
--- perhaps some teaser paragraph as what the user will be expecting is they registered and logged in ---
[/s2If] 

Or a more advance approach would be (if you are using a theme like TwentyEleven or a Wootheme Theme or something similar):

You could enter some teasers on the Excerpt of the post while the Content contains the restricted article and video. Then add this inside your Loop routine, along after the “the_post();” statement:

<?php if (is_user_logged_in()){
  the_content();
  } else {
  the_excerpt();
  }
?>

This way the teaser which is from the Excerpt will be shown to the users who are not logged in. But if the user has logged in and if they have access to the post, the content of the posts will be shown. You can still use some combinations of the [ s2If ] and other shortcodes to get your desired results.

Posted: Monday Jul 9th, 2012 at 3:10 pm #18691
Eduan
Username: Eduan
Moderator

Tom,

As CodeClips suggested, I would use s2Member conditionals for separating the video from the rest.

You might actually be interested in actually putting a little teaser with these conditionals.

You can find the simple/shortcode conditionals under Dashboard -› s2Member® -› API / Scripting -› Simple/Shortcode Conditionals.

Hope this helps. :)

Posted: Tuesday Jul 10th, 2012 at 3:52 pm #18828
Echomango
Username: echomango

CodeClips and Eduan – Many thanks! It will likely take me a while to digest this and also put it into proctice.

I think what you are saying is when you are creating the post witnin wordpress that you use the S2 conditional tags to exclude the video from the post. That would be a very good solution indeed! I will experiment tonght and see what happens.

I think I am using tenty-eleven. It was the one that came with the installation and i haved not bothered to try and work with a new theme at this point.

I do appreciate your help with this.

T

Posted: Tuesday Jul 10th, 2012 at 9:21 pm #18853
Echomango
Username: echomango

Those tags are exactly what I needed! They work great and are simple and elegant. I love it and can’t thank you both enough for leading me to this.

I did notice that when the upper tag looks like this

[s2If current_user_is(s2member_level0)]

It still prevents the content from displaying. This confuses me a bit since it seems to be set to level 0. Isn’t level 0 open to the public?

It looks like anything that gets put between those tags is not shown, even if the tag is set to level 0.

Posted: Tuesday Jul 10th, 2012 at 9:47 pm #18854
CodeClips
Username: codeclips

The [s2If current_user_is(s2member_level0)] shows the enclosed content only to the logged in users.

If you want to show it to non logged in users or to the public, use [s2If !is_user_logged_in()] instead. Note the ! means “not”.

For the logged in users, use [s2If is_user_logged_in()] or [s2If current_user_is(s2member_level0)]

Posted: Wednesday Jul 11th, 2012 at 10:56 am #18925
Eduan
Username: Eduan
Moderator

Just to note CodeClips,
[s2If current_user_is(s2member_level0)] will only display content to level 0 users, no less, no more. If you want it to display to any user that’s logged in simply use [s2If is_user_logged_in()] like you said, or [s2If current_user_can(s2member_level0)].

If you want to display content to all paid members just modify the [s2If current_user_can(s2member_level0)] one to represent the level you want as a minimum.

Hope this clears something up. :)

Viewing 11 replies - 1 through 11 (of 11 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.