Title: Can&#8217;t validate input
Last modified: March 5, 2018

---

# Can’t validate input

 *  Resolved [hobotechnologies](https://wordpress.org/support/users/hobotechnologies/)
 * (@hobotechnologies)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/cant-validate-input/)
 * WordPress 4.9.4 running Mindstream Child Theme theme.
    Running PHP version: 5.6.31-
   4+wpengine10
 * Hi – I’m demoing the free version of Mail Chimp for WordPress…hoping to get this
   working and then buy the full version.
 * there’s basically one thing I need it to do: collect emails and validate a predetermined
   code that the user needs to know in order to get a download.
 * I have added your validation code to functions.php and changed the necessary 
   values to match my needs:
 * if( $_POST[‘CODE’] !== ‘GIMMEPOWER’ ) {
 * (full code at bottom of post)
 * With the code in functions.php, the validation code rejects all input whether
   or not it is correct.
 * I have also tried moving the code to the plugin editor you suggest (My Custom
   Functions), and also to the Body Scripts field of a page that references the 
   shortcode for your form. In both of these cases, the validation code does nothing
   and allows all input.
 * —CODE:
 * /**
    * Performs additional form validation on MailChimp for WP forms
 * *
 * * [@return](https://wordpress.org/support/users/return/) array An array of error
   codes.
 * */
 * function myprefix_validate_mc4wp_form( $errors ) {
 * // perform validation here
 * if( $_POST[‘CODE’] !== ‘GIMMEPOWER’ ) {
 * $errors[] = ‘incorrect_value’;
 * }
 * return $errors;
 * }
 * add_filter( ‘mc4wp_form_errors’, ‘myprefix_validate_mc4wp_form’ );
 * /**
 * * Registers an additional MailChimp for WP error message
 * *
 * * [@return](https://wordpress.org/support/users/return/) array Array of messages
 * */
 * function myprefix_add_mc4wp_error_message( $messages ) {
 * $messages[‘incorrect_value’] = ‘Please enter the correct value.’;
 * return $messages;
 * }
 * add_filter( ‘mc4wp_form_messages’, ‘myprefix_add_mc4wp_error_message’ );
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcant-validate-input%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [hobotechnologies](https://wordpress.org/support/users/hobotechnologies/)
 * (@hobotechnologies)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/cant-validate-input/#post-10042463)
 * Ok, I think I’ve sorted it out. I do very little programming these days…I had
   popped open the file in TextEditor on OS X and got screwed by the “Smart Quotes”
   function. After correcting the quotes, the code seems to work fine.
 *  Plugin Author [Danny van Kooten](https://wordpress.org/support/users/dvankooten/)
 * (@dvankooten)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/cant-validate-input/#post-10043103)
 * Hey Hobotechnologies,
 * Hah, it happens to the best of us. Glad to hear that it is all working now! Thank
   you for updating this thread to let us know.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Can’t validate input’ is closed to new replies.

 * ![](https://ps.w.org/mailchimp-for-wp/assets/icon-256x256.png?rev=1224577)
 * [MC4WP: Mailchimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mailchimp-for-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mailchimp-for-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/mailchimp-for-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mailchimp-for-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mailchimp-for-wp/reviews/)

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [validation](https://wordpress.org/support/topic-tag/validation/)

 * 2 replies
 * 2 participants
 * Last reply from: [Danny van Kooten](https://wordpress.org/support/users/dvankooten/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/cant-validate-input/#post-10043103)
 * Status: resolved