Support » Plugin: MailChimp for WordPress » Can’t validate input

  • Resolved hobotechnologies


    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.


    * Performs additional form validation on MailChimp for WP forms


    * @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 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 to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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


    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.