0

I have a plugin with a registration_errors filter to prevent users from using a .gov email address. I have this code in the "registration_errors" filter function:

$errors->add( 'gov_email',
        'Please provide a private email address. not an official work email address.');
}

I want to shake the login form when the error is encountered so I added this to my plugin:

$shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password', 'retrieve_password_email_failure', 'gov_email' );
add_filter( 'shake_error_codes', $shake_error_codes );

Note the gov_email at the end of the array in the code above to try to add the custom error code.

Not only does this not work, but the form no longer shakes for other errors, either.

Also tried this:

add_filter( 'shake_error_codes', 'custom_add_error_code');
function custom_add_error_code($error_code) {
    return array_push($error_code, 'gov_email');
}

This did not work, either.

1 Answer 1

0

OK, my php is a little rusty. Doing a "return" on an array_push does not return the array. So had to change my add_filter to:

add_filter( 'shake_error_codes', 'custom_add_error_code');
function custom_add_error_code($error_code) {
    array_push($error_code, 'gov_email');
    return $error_code;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.