Hello Dave72,
If you want to redirect Specific Post/Pages to a separate purchase page (instead of using the Membership Options page), you will need to create a
WordPress Page Template for your Membership Options Page and then add PHP code to the top of that template.
(You could also insert this code into your theme's
page.php template, but it's cleaner to create a separate Page Template.)
The comments in the code below should explain how it works. Basically you need to detect when someone is being redirected to the Membership Options Page, determine which Specific Post/Page they were trying to access (using the page/post ID), and then redirect them to the correct page where they can purchase that Specific Post/Page with a Buy Now button (you'll need to create the purchase page for each Specific Post/Page and add the correct URLs to the code).
- Code: Select all
<?php
if(isset($_GET['s2member_seeking'])) { $url_attempt = $_GET['s2member_seeking']; }
if($url_attempt){
$url_attempt = str_replace(" ", "", $url_attempt);
$id_attempt = explode("-", $url_attempt);
$id_attempt = $id_attempt[1];
if(is_numeric($id_attempt)){
switch($id_attempt) {
case "12214": $purchase_page = "http://example.com/purchase-page-for-12214/"; break;
case "12315": $purchase_page = "http://example.com/purchase-page-for-12315/"; break;
default: $purchase_page = "";
break;
}
if(trim($purchase_page) != "") {
?>
<script type="text/javascript">
<!--
window.location = "<?php echo $purchase_page; ?>";
//-->
</script>
<?php
}
}
}
?>
Once you create the page template and add this code, you will need to assign that page template to your Membership Options Page: Toward the bottom of the Write > Page administration panel is a drop-down labeled "Page Template"; from there you can select which Template will be used when displaying this particular Page.
If you're not familiar with WordPress Page Templates, you should read more about them here:
http://codex.wordpress.org/Pages#Page_TemplatesYou can also read more about the variables available to the Membership Options Page here:
WP Admin -> s2Member -> API / Scripting -> Membership Options Page / Variables.
Please let me know if this works for you!
