0

I have created a contact page, and all I want is to make the variable $emailto be dynamique.

What i mean is i have an option page on the backend and I want to let administrator change the contact email.

enter code here
if(!isset($hasError)) {

        $emailTo = 'contact@sophrologie.com';
        $subject = 'Formulaire du contact '.$name;
        $sendCopy = trim($_POST['sendCopy']);
        $body = "Nom et prénom: $name \n\nEmail: $email \n\nSujet: $sujet\n\nComments: $comments";
        $headers = 'De : mon site <'.$emailTo.'>' . "\r\n" . 'Répondre à : ' . $email;

        mail($emailTo, $subject, $body, $headers);

        if($sendCopy == true) {
            $subject = 'Formulaire de contact';
            $headers = 'De : <noreply@somedomain.com>';
            mail($email, $subject, $body, $headers);
        }

        $emailSent = true;

    }

Now there is what I wanna do :

$emailTo = echo wpJediOptions::get_option('my_option', 'email_1');

The problem is we can't use an echo with = operator so what I need to do ???

EDIT

I have created an option page on the back-end with some input so to show what the administrater is puting in the input.

For exemple i had an input for email, to show this email on a cotact page i need to do this :

<li class="ema">E-mail : <?php echo wpJediOptions::get_option('achraf_option', 'mail_1'); ?></li>

what i wanna know is how to do the same for this variable $emailTo.

this variable serve to send the contact form to this email.

  • Er, remove the echo ?! – bonger Jul 3 '15 at 21:23
  • see my comment below. – Carl Willis Jul 3 '15 at 22:11
0

Is this what you are looking for? You want to get the option and output it?

$emailTo = wpJediOptions::get_option('my_option', 'email_1');
echo $emailTo;
  • No, sorry I forgot to tell you I'm using a class named wpJediOptions. And to show the option I need the echo, thats why i can't figure out how to show my option. – Carl Willis Jul 3 '15 at 22:08
  • I'm a bit confused. You might have to explain it a bit more. Where do you want to echo out $emailTo? What are you trying to achieve with $emailTo = echo wpJediOptions::get_option('my_option', 'email_1');? – true Jul 3 '15 at 23:20
  • see my edit in the post. – Carl Willis Jul 3 '15 at 23:27
  • Ok, thank you, so about the $emailTo variable. Where is it being set/defined, and where do you want it to be echoed out? What does this variable contain? Where is it being assigned the data? – true Jul 3 '15 at 23:33
  • I have all the code for the contact form but this variable is setted in the code above with the mail function. – Carl Willis Jul 3 '15 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.