[S2if] Conditional Statements - Template for various pages? - Guidance Please. :)

Hello All! I am creating some conditional statements that are going to be used on 100’s of pages. There a probably 3 or 4 different conditional statements that will go through out on all of these pages.

Is there a way to create a conditional statement once and then use it in a template type way so that if I want to change something in the conditional statement I don’t have to do it on 500 different pages?

Thanks!

Sure! See API/Scripting -> Advanced/PHP Conditionals

Hello KTS915. Thank you for the quick response. Ok, please excuse my ignorance when it comes to PHP. Would I create a function somewhere and then put that function into my page? I understand the coding portion, I’m just not 100% sure on where I need to put this code. Thanks!!!

The best way would be to use a child theme, and then include the conditional in the template for posts, pages, or custom posts, according to where it will be used.

Hi KTS915. Thank you for putting me on the correct path. Again forgive me for my ignorance. :grimacing:

So what I need to do in my child themes function.php file is create my conditional statement custom function and then put “<?php echo custom_function ('level_user'); ?>” on my page where I want the function to run with “level_user” being the variable I get from my page?

I’m not for sure what variable I need put in “level_user”. Is there a variable for S2Member role? I think I have read about it somewhere, but can’t seem to find it now.

Thanks!

@MoeJoe: It’s all explained in the section to which I referred you. I can’t explain it any better. If you still can’t make it work, then you’ll need to hire a developer.

I will take a look and get it figured out. I can’t tell you how much I appreciate you pointing me in the right direction. It’s hard when you know what you want to do and you have some of the picture, but you don’t know exactly how to ask for the full picture. :relaxed:

Thanks