Hi All
I imagine this is a very simple question (hence the $5 reward) but I can't quickly find the answer.
I'm using some if/then commands in my functions.php file to include files, using TEMPLATEPATH, depending on whether a person that fills out a form selects A, B or Both. If the person selects A, file A is included; if the person selects B, file B is included. So far so good. The code (which I think is using a Gravity Forms hook) looks a bit like this and works fine:
$cc_licences = $_POST["input_35"];
if($cc_licences == "Creative Commons Attribution-Non Commercial (CC BY-NC) licence"){ include( TEMPLATEPATH . '/files/cc_by_nc.php' );
}
But if the person selects Both, I want to be able to include both file A and file B. So my question please is this: Is it possible to use the "include(TEMPLATEPATH . " approach and include two (or more) files rather than one? If so, can someone give me the sample code please?
Many thanks for your help. And thanks WPQuestions. A great service.
Richard
Utkarsh Kukreti answers:
include( TEMPLATEPATH . '/files/file1.php' );
include( TEMPLATEPATH . '/files/file2.php' );
Agent Wordpress answers:
$cc_licences = $_POST["input_35"];
$cc_other = $_POST["something"];
if($cc_licences == "Creative Commons Attribution-Non Commercial (CC BY-NC) licence")
{
include( TEMPLATEPATH . '/files/file1.php' );
}
if($cc_other == "something else")
{
include( TEMPLATEPATH . '/files/file2.php' );
}
This way both files will be included if both conditions are true. But if only one of them is true, then only that file will be included.
(I have used dummy variable $cc_other for demonstration purpose)
Richard comments:
Thanks very much all. Much appreciate. I've chosen Uktarsh on a first answer first paid basis.
What a great service. I'm sure I'll be back with more questions.
Thanks again
Richard