I have a newsletter form in my wordpress site which supposed to be used through the shortcode :
<form action="newsletter.php" method="post">
...
</form>
And the shortcode should look :
[newsletter]
In my theme option i have an input field to enter the email address. That value needs to be stored in newsletter.php in the variable $to
How can i ‘connect’ the newsletter.php with the wordpress get_option for that input i have?
newsletter.php :
<?php
$email = $_POST['news'];
// --- this should be the option from the wordpress panel -------
$to = "mail@mail.com";
// ---------------------------------
$subject = "newsletter request";
$date = date("d-m-Y");
$email_message = " Newsletter request : rn";
$email_message .= " ================================================== rn ";
$email_message .= "This user wants to be notified about your website launch : ".$email."rn";
$email_message .= " ================================================== rn";
$email_message .= " Request was sent " .$date. " rn";
$headers = 'From: '.$email."rn";
if($email != null && $email != ""){
mail($to,$subject,$email_message,$headers);
}
header("location:../index.php");
?>
I tried with REQUIRE_ONCE but, that isn’t working…
Well you have to create a plugin, I am giving instruction to create a simple plugin. I say again SIMPLE. And its not the only way to create a plugin, but it will be easy one for you.
Create a file in
plugins
folder and do code like thisActivate this plugin from admin panel and create a page, write
[myplugin]
in content. And give your form action to this page’s permalink.More details can be found at http://codex.wordpress.org/Writing_a_Plugin