im trying to create a WordPress plugin for first time.
What i want from this plugin is really simple. I need to show form with 2 fields one for Subject second for message. Then take all registered users emails and use this data in wp_mail.
Then use short code soo i can display that form on front end. Just need to make possible send information imail to all registered users from front end.
Im trying this code:
if(isset($_POST['button1'])) {
showtext();
}
function show_form(){
echo ' <form method="post">
<input type="submit" name="button1" value="Button1"/>
</form>
';
}
function showtext(){
echo "text";
}
function group_email_shortcode() {
$odeslano=wp_mail( 'jindra.kos@seznam.cz', 'The subject', 'The message' );
if($odeslano) {
return "odeslano";
}//message sent!
else {
return "chyba";
}//message wasn't sent
}
add_shortcode( 'helloworld', 'show_form' );
If i call function for sending email in short code then it will send email and its working. When i try to call function where im showing form and from that form im calling function for sending email its not working and it shows me info about crytical error on page.. I have read a lots of stuffs, but i cant find any hint what im making wrong.