Hi @kirilb,
Thanks for reaching out!
We reviewed that code, and here are some codes that should work to hide a form on mobile:
/**
* 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 );
or
/**
* Hide the form on mobile devices
*
* @param bool $show
* @param array $form_data
* @return bool
*/
function my_custom_function($form, $form_data ) {
if ( wp_is_mobile() ) {
return true;
}
}
add_filter( 'wpforms_frontend_output_form_is_empty', 'my_custom_function',10,2);
In case it helps, here’s our tutorial with the most common ways to add custom code like this.
For the most beginner-friendly option in that tutorial, I’d recommend using the WPCode plugin.
Hope this helps!