This hook can be used to change the visibility of an element. Elements that are not visible are not shown in the form or processed.
quform_element_visible_X_X
This hook is run for a single element.
Example
12
3
4
5
6
7
| add_filter('quform_element_visible_1_3', function ($visible, Quform_Element $element, Quform_Form $form) { if (is_user_logged_in()) { $visible = false; } return $visible; }, 10, 3); |
add_filter('quform_element_visible_1_3', function ($visible, Quform_Element $element, Quform_Form $form) { if (is_user_logged_in()) { $visible = false; } return $visible; }, 10, 3);
- On line 1, replace the
1_3
with the element unique ID
1
2
3
4
5
6
7
8
9 | function my_element_visible($visible, Quform_Element $element, Quform_Form $form) { if (is_user_logged_in()) { $visible = false; } return $visible; } add_filter('quform_element_visible_1_3', 'my_element_visible', 10, 3); |
function my_element_visible($visible, Quform_Element $element, Quform_Form $form) { if (is_user_logged_in()) { $visible = false; } return $visible; } add_filter('quform_element_visible_1_3', 'my_element_visible', 10, 3);
- On line 9, replace the
1_3
with the element unique ID
quform_element_visible
This hook is run for all elements.
Example
1 2 3 4 5 6 7 | add_filter('quform_element_visible', function ($visible, Quform_Element $element, Quform_Form $form) { if (is_user_logged_in()) { $visible = false; } return $visible; }, 10, 3); |
add_filter('quform_element_visible', function ($visible, Quform_Element $element, Quform_Form $form) { if (is_user_logged_in()) { $visible = false; } return $visible; }, 10, 3);
1 2 3 4 5 6 7 8 9 | function my_element_visible($visible, Quform_Element $element, Quform_Form $form) { if (is_user_logged_in()) { $visible = false; } return $visible; } add_filter('quform_element_visible', 'my_element_visible', 10, 3); |
function my_element_visible($visible, Quform_Element $element, Quform_Form $form) { if (is_user_logged_in()) { $visible = false; } return $visible; } add_filter('quform_element_visible', 'my_element_visible', 10, 3);
Parameters
$visible
–boolean
– whether the element is currently visible or not$element
–Quform_Element
– the element instance$form
–Quform_Form
– the form instance