Skip to content

Instantly share code, notes, and snippets.

@slaFFik
Created September 25, 2017 13:38
Show Gist options
  • Save slaFFik/733f5957911a27dc6076cadf11b21d3c to your computer and use it in GitHub Desktop.
Save slaFFik/733f5957911a27dc6076cadf11b21d3c to your computer and use it in GitHub Desktop.
WPForms: Hide forms on mobile
<?php
add_filter( 'wpforms_frontend_load', function( $load, $form_data, $var ) {
// Comment these lines if you need to hide a certain form only.
if ( wp_is_mobile() ) {
return false;
}
// Or check certain form only. Uncomment.
/*
if ( 123 == $form_data['id'] ) {
return false;
}
*/
return $load;
});
@mkipruto
Copy link

mkipruto commented Nov 1, 2023

/**
 * Hide the form with ID 685 on mobile devices.
 *
 * @param bool $show
 * @param array $form_data
 * @return bool
 */
add_filter( 'wpforms_frontend_load', function( $show, $form_data ) {
    if ( wp_is_mobile() && $form_data['id'] == 685 ) {
        return false; // Hide the form with ID 685 on mobile devices.
    }

    return $show; // Show other forms and the form with ID 685 on non-mobile devices.
}, 10, 2 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment