Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active February 1, 2017 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/6b64009036b964ea6e7bd5ada57eb9c5 to your computer and use it in GitHub Desktop.
Save joshfeck/6b64009036b964ea6e7bd5ada57eb9c5 to your computer and use it in GitHub Desktop.
Remove JavaScript validation for the email field in EE3. First example requires WordPress 4.5 or greater. See other code example for sites that have WP 4.4 or lower.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function eethree_jquery_validator_custom(){
wp_add_inline_script(
'validation',
'jQuery(document).ready(function($){
$(".email").removeClass("required");
$("label[for=\'email\'] em").hide();
});'
);
}
add_action( 'wp_enqueue_scripts', 'eethree_jquery_validator_custom', 50 );
<?php
//* For sites with WP 4.4 or lower. Doesn't use wp_add_inline_script().
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function eethree_jquery_validator_custom(){
if( wp_script_is( 'validation', 'done' ) ) {
?>
<script>jQuery(document).ready(function($){
$(".email").removeClass("required");
$("label[for='email'] em").hide();
});
</script>
<?php
}
}
add_action( 'wp_print_footer_scripts', 'eethree_jquery_validator_custom', 50 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment