Archived

This topic is now archived and is closed to further replies.

  • 0

s2Member php scripts : in a PL custom page template ?


Question

Posted · Report post

Hi,

 

I would really need to use s2Member scripts related to "Membership Options Page [aka MOP] Variables", for instance for displaying dynamic information on my MOP page such as what the user / member was attempting to access before they were redirected to it.

s2Member plugin provides code snippets, e.g. :

<?php
$_g = stripslashes_deep ($_GET);
if (isset ($_g["_s2member_seeking"]["type"]) /* One of: page|post|catg|ptag|file|ruri */ )
    echo 'You were trying to access a protected: ' . esc_html ($_g["_s2member_seeking"]["type"]) . '.';

My problem is: where should I put this kind of code?

 

Is it logical (I was said so...) and possible to put it in a custom page template (let's say: the 'pagemystwomember.php' file I created in my child theme and use for drag & drop) and affect this template to my s2Member MOP page?

Or should I rather put directly the code in my page (using a plugin like "Allow PHP in Posts and Pages"?

Many thanks in advance.

Share this post


Link to post
Share on other sites

5 answers to this question

Posted · Report post

Hi there,

 

That's great news the plugin code in the contentbox worked.

 

Unfortunately you're correct with the page template files, the actual data within those template files pulls the php/code from other files within the framework, depending on what sections are present in the template on the drag and drop page.

 

If you were to enter custom code directly into the template.php file it could affect the setup of the template and stop any other sections from being pulled in etc. Plus any content you put into those files would be wiped each time you updated the framework, which is why they suggest using hte functions.php of a child theme or the customize plugin as this will be safe from updates as it's outside of the core files.

1 person likes this

Share this post


Link to post
Share on other sites

Posted · Report post

Hi James,

  • Thanks for the good idea: I never thought about boxes this way, especially ContentBoxes. I placed my code in ContentBoxes (and "standard" Boxes too!) using the plugin I mentioned Allow PHP in Posts and Pages: it does work ;) !
     
  • This is of course a compromise solution and I would really have prefered to be able to use "real / full php": this plugin has some restrictions + it's not really what s2Member recommends i.e. use a seperate page template. But my knowledge of WordPress hooks is too limited for editing my child theme functions.php to achieve the same result (on the condition it is really relevant in this context, which I doubt).
     
  • In order to put an end to this topic: if I understand you correctly, my custom page template files are not supposed to content anything else than the template name and the following code, and cannot be a solution here in no way at all?
<?php
setup_pagelines_template();

Share this post


Link to post
Share on other sites

Posted · Report post

Hi there,

 

I think I'm following what you mean. So the plugin hides the content regardless, you just want the additional message to appear if it does block the content?

 

The easiest option would to be to use a plugin like you've mentioned and place the code into a contentbox which has been placed into the layout via the drag and drop editor.

 

As we're not a standard theme, if you wanted to place the php code directly into the child theme's functions php I would think you'd need to edit it into a worpdress filter so it work correctly. More information on wordpress filters can be found at - http://codex.wordpress.org/Plugin_API/Filter_Reference and http://wp.tutsplus.com/tutorials/the-beginners-guide-to-wordpress-actions-and-filters/

Share this post


Link to post
Share on other sites

Posted · Report post

Thanks for everything: marked as solved ;) !

Share this post


Link to post
Share on other sites

Posted · Report post

Great!

Share this post


Link to post
Share on other sites