Skip to content

Instantly share code, notes, and snippets.

@webdevsuperfast
Last active September 5, 2018 19:30
Show Gist options
  • Select an option

  • Save webdevsuperfast/e17c3f14fc17e029c95072f657b68704 to your computer and use it in GitHub Desktop.

Select an option

Save webdevsuperfast/e17c3f14fc17e029c95072f657b68704 to your computer and use it in GitHub Desktop.
Disable Gravity Forms Captcha on Mobile
<?php
add_filter( 'gform_pre_render', 'disable_captcha' );
add_filter( 'gform_pre_validation', 'disable_captcha' );
// add_filter( 'gform_pre_validation', 'disable_captcha' );
// add_filter( 'gform_admin_pre_render', 'disable_captcha' );
add_filter( 'gform_pre_submission_filter', 'disable_captcha' );
function disable_captcha( $form ) {
foreach( $form['fields'] as $key => $field ) {
if ( $field->type === 'captcha' && wp_is_mobile() ) {
unset( $form['fields'][$key] );
}
}
return $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment