Community Support Forums — WordPress® ( Users Helping Users ) — 2011-11-21T03:47:29-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=14947 2011-11-21T03:47:29-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14947&p=53597#p53597 <![CDATA[Re: Redirected From Restricted Content - Using Variables.]]>

MOP vars have changed a bit lately, please check the documentation in the latest release. It should be simpler to code this now. WP Admin -> s2Member -> API / Scripting -> Membership Options Page Variables

I hope it helps.

Statistics: Posted by Cristián Lávaque — November 21st, 2011, 3:47 am


]]>
2011-11-19T19:11:55-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14947&p=53487#p53487 <![CDATA[Re: Redirected From Restricted Content - Using Variables.]]>
This code would need to be placed at the top of your theme's page.php file, or a separate Page Template for the Membership Options Page; using a Page Template is a much cleaner method, as you don't really want this code running for every single WordPress page.

The comments in the code below should explain how it works. Basically we 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 and post/page IDs to the code).

Code:

<?php
// Check if this is a redirect from a restricted page
if(isset($_GET['s2member_seeking'])) { $url_attempt = $_GET['s2member_seeking']; }
    if($url_attempt){
        // Extract the Specific Post/Page ID that the user is attempting to access
        $url_attempt = str_replace(" ", "", $url_attempt);
        $id_attempt = explode("-", $url_attempt);
        $id_attempt = $id_attempt[1];
        
        if
(is_numeric($id_attempt)){
                // Check if the Specific Page/Post ID is one that 
                // we want to redirect to its own Purchase Page.
                // You can add new case statements for every page
                // that you want to redirect. Make sure the case
                // statement ends with break;
                switch($id_attempt) {
                    case "12214": // Specific Page/Post ID
                        $purchase_page = "http://example.com/purchase-page-for-12214/"; // Purchase page
                        break;
                        
                    case 
"12315": // Specific Page/Post ID
                        $purchase_page = "http://example.com/purchase-page-for-12315/"; // Purchase page
                        break;                        
                        
                    default
: // Always leave this here
                        $purchase_page = "";
                        break;
                }
                
                
// If we need to redirect
                if(trim($purchase_page) != "") {
                    
                    
// Use JavaScript to redirect to the correct purchase page
                    ?>
                    
                    <script type="text/javascript">
                    <!--
                    window.location = "<?php echo $purchase_page; ?>";
                    //-->
                    </script>
                    
                    <?php
                
}
                
            
}
        } 
?>

Statistics: Posted by Raam Dev — November 19th, 2011, 7:11 pm


]]>
2011-09-10T02:28:10-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14947&p=34465#p34465 <![CDATA[Re: Redirected From Restricted Content - Using Variables.]]>

And thanks for sharing that, I'm sure it'll help others trying to do something similar.

Statistics: Posted by Cristián Lávaque — September 10th, 2011, 2:28 am


]]>
2011-09-09T21:34:53-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14947&p=34435#p34435 <![CDATA[Redirected From Restricted Content - Using Variables.]]>
If a user is trying to access restricted content, they get forwarded to the page you choose in the options, with some variables in the query string.

Under the API / Scripting -> Membership Options Page Variables, it shows the custom links based on redirection. Documentation is great describing the variables in the links. Here's how I put it to use:

Code:


<?php

// What level they need to be.  I'm not using this for now as I only have one premium level 
// $level_required = $_GET['s2member_level_req'];     


$url_attempt $_GET['s2member_seeking'];  // What page/post they were trying to access    
        
    
if($url_attempt){                                   // If it was a redirect
        
$url_attempt str_replace(" """$url_attempt);  //Ensure no spaces (shouldn't be issue)
        
$id_attempt explode("-"$url_attempt);            // Seperate post/page and ID
        

                // This would tell if you if post, page, or other  (I'm not using this for now)
        // echo 'page/post ', $id_attempt[0];  

        
if(is_numeric(end($id_attempt))){    // if page/post is a number - ID ?>
            
            <p> Sorry "<?php echo get_the_title(end($id_attempt)); ?>" is for members only.  Check out our awesome deals below to get access to the templates, along with tools, plugins, and other goodies!</p>
            <br />    
            <?php            
          
// Of course you might want to be more specific depending on what they were trying to access
        
}
    }    
?>


Hope it's of some assistance to someone.

Cheers!

PS Loving the amazing extensibility of the plugin and how incredibly thorough it is. Very well done!

Statistics: Posted by son0fhobs — September 9th, 2011, 9:34 pm


]]>