Plugin echo error
-
Hey folks, new to plugin development and I imagine someone will be able to tell me exactly what is happening here rather easily.
I did not attach a website link as it only shows the error on the back end and the code works as expected I just cant figure out why I am getting this error.
I made a simple plugin that is an unsubscribe input box entry so when you put in an email address the server sends an email to the server admin that someone would like to unsubscribe (I know a plugin probably already exists for this but I am more trying to learn than anything else)
here is my code;
function email_unsubscribe(){ echo "<form action='' method='post'>"; echo "<input type='email' id='email' name='email'><br><br>"; echo "<input type='submit'></form>"; if (!empty($_POST)) { $email = $_POST['email']; echo $email; ///just echo for testing so I dont get emails } } add_shortcode( 'unsubscribe', 'email_unsubscribe' ); ?>
When I use the shortcode [unsubscribe] and hit update I get the error;
Updating failed. The response is not a valid JSON response.
However when I go to that page the input box is there and it works correctly.
I have noticed the echo command seems to be the reason this is happening.What am I missing?
- The topic ‘Plugin echo error’ is closed to new replies.