Jump to content


Photo
- - - - -

s2Member php scripts : in a PL custom page template ?

s2Member

Best Answer James B , 19 June 2013 - 11:36 PM

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.

Go to the full post


  • Please log in to reply
5 replies to this topic

#1 Erwan

Erwan

    Super Member

  • Members

  • 193 posts
  • Framework Version:Framework 2.4.4 - DMS 1.1.6 & 1.2
  • Country: Country Flag

Posted 17 June 2013 - 04:44 PM

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. :

Please Login or Register to see this Hidden Content

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.



#2 James B

James B

    Advocate

  • Members

  • 5126 posts
  • LocationSurrey - UK
  • Country: Country Flag

Posted 17 June 2013 - 08:52 PM

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 -

Please Login or Register to see this Hidden Content

and http://wp.tutsplus.com/tutorials/the-beginners-guide-to-wordpress-actions-and-filters/



#3 Erwan

Erwan

    Super Member

  • Members

  • 193 posts
  • Framework Version:Framework 2.4.4 - DMS 1.1.6 & 1.2
  • Country: Country Flag

Posted 19 June 2013 - 02:35 PM

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

    Please Login or Register to see this Hidden Content

    : 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?

Please Login or Register to see this Hidden Content



#4 James B

James B

    Advocate

  • Members

  • 5126 posts
  • LocationSurrey - UK
  • Country: Country Flag

Posted 19 June 2013 - 11:36 PM   Best Answer

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.


  • Erwan likes this

#5 Erwan

Erwan

    Super Member

  • Members

  • 193 posts
  • Framework Version:Framework 2.4.4 - DMS 1.1.6 & 1.2
  • Country: Country Flag

Posted 20 June 2013 - 09:14 AM

Thanks for everything: marked as solved ;) !



#6 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 20 June 2013 - 01:24 PM

Great!