Skip to content

Instantly share code, notes, and snippets.

@jeffsebring
Last active October 12, 2015 00:17
Show Gist options
  • Save jeffsebring/3941807 to your computer and use it in GitHub Desktop.
Save jeffsebring/3941807 to your computer and use it in GitHub Desktop.
Hidden Gravity Forms Validation & Confirmation
# Use the wp_enqueue_scripts hook to enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'mytheme_enqueue', 99999);
# Callback function
function mytheme_enqueue()
{
wp_enqueue_script( 'mytheme', get_stylesheet_directory_uri() . '/javascripts/theme.js', array( 'jquery' ), '', 'footer' );
}
.contact_form {
display: none;
}
jQuery(document).ready(function() {
$( '.contact_link' ).click( function() {
$( '.contact_form' ).toggle( 'slow' );
$('html, body').animate({scrollTop:$(document).height()}, 'slow');
});
});
<div class="contact">
<div class="contact_form">
<?php echo do_shortcode( '[gravityform id="1" title="true" description="false"]' ); ?>
</div>
<a class="contact_link" href="javascript:void(null);" title="Contact Support">Contact Support</a>
</div>
# Was this form submitted?
if ( isset( $_POST[ 'is_submit_1' ] ) ) :
# Print our javascript in the footer.
add_action( 'wp_footer', function()
{ ?>
<script>
jQuery(document).ready(function() {
$( '.contact_form' ).toggle( 0 );
$('html, body').animate({scrollTop:$(document).height()}, 0);
});
</script>
<?php }, 99999);
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment