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.

Show excerpt on post url for protected conten

Home Forums Community Forum Show excerpt on post url for protected conten

This topic contains 3 replies, has 2 voices. Last updated by  David Welch 4 years, 9 months ago.

Topic Author Topic
Posted: Tuesday Mar 20th, 2012 at 10:31 am #8605
Bryan Ragon
Username: BryanLR

Okay, I know there are a *lot* of posts about excerpts and protected content… I’ve read many, many of them and am still having some problems finding a solution that I’d like. Basically, we have an entire category that is protected. It still allows excerpts (manual or autogenerated) to be viewed by an un-privledged user, which is good. It works on archive pages, feeds, etc… just the way we want. However, is there a way to get the full URL of the post to not re-direct to the “Buy a membership” page, but instead to show the excerpt again and then a custom “ad” under it basically saying, hey click here to buy a membership?

I know this could be done using conditionals, but I’m trying to make is as simple as possible for our authors.

Thanks!!

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Tuesday Mar 20th, 2012 at 11:10 am #8607
David Welch
Username: dwbiz05

First thought, which usually means its the most complicated way I can think to do it… lol.

Off the top of my head this is what I would do.

1. create a new page template in your theme that pulls a $_GET variable for the post_id then displays only the excerpt and the ad you want to display underneath. or if you are using a php execute plugin, you may be able to do this in a page itself without creating a theme template. you may have to play with it a little.
2. create a page (blank maybe or with the ad, not sure) titled something like “Ad Page” and select the new template for that page.
3. create a function like this and add it to your functions.php file or your mu-plugins/s2hacks.php file:

<?php
add_action("ws_plugin__s2member_before_wp_redirect_w_mop_vars","my_post_redirect");
add_action("ws_plugin__s2member_before_wp_redirect_wo_mop_vars","my_post_redirect"); // not sure which is best hook to use.

function my_post_redirect($vars=array()){
	//die(print_r($vars));
	if($vars['seeking_type'] == 'post'){
		$post_id = $vars['seeking_type_value'];
		//maybe add some more filtering to check if it's a specific post category or something.
		wp_redirect(site_url('ad-page/?post_id='.$post_id)); // Change ad-page to the slug of your page and make sure the $_GET['post_id'] is being checked.
	}
}
?>

If I have the right hook, this should automatically pull the id of the post and send it to you’re page for showing the add and the excerpt.

I’ve not tested this fully but initial tests seemed to work fine.

Hope that helps,
Dave

Posted: Tuesday Mar 20th, 2012 at 11:34 am #8610
Bryan Ragon
Username: BryanLR

Hmmm… this could work I think. The only thing I don’t like is that the full URL is different between the “excerpt with ad teaser” “page” and the permalink of the full post.

Is there a way to turn off permalink protection for a specific category? And then I could edit single.php so that if the category is a protected category, then to display the excerpt and ad, of if the user has access display the full post.

Come to think of it… Hmmm…. what issues would happen if I simply removed this category from S2’s protection altogether? I assume I can still do the necessary current_user_can(“access_s2member_level1”) in single.php manually. So basically I would be using S2 for registration and purchase, but “rolling my own” protection built into my theme. Is there anywhere else besides single.php where the entire post is displayed? Doesn’t everywhere else automatically use the excerpt (Which we want publicly available anyway)?

Posted: Tuesday Mar 20th, 2012 at 11:53 am #8614
David Welch
Username: dwbiz05

LOL… see, my first way is always more complicated… lol.

I think you have a good idea by editing the single page. I don’t remember off the top of my head if it’s displayed elsewhere as the full article.

Dave

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.