Created
October 5, 2021 16:15
-
-
Save nkb-bd/4c76a6ecf7f523854cdb4a5e77a0dff1 to your computer and use it in GitHub Desktop.
Preselect chekbox/radio from get parameter in WP FLuent Forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter('fluentform_rendering_field_data_input_checkbox', function ($data, $form) { | |
| { | |
| //change form ID | |
| if ($form->id != 5) { | |
| return $data; | |
| } | |
| //set get param value & match with checkbox value | |
| if (isset($_GET['my_value'])) { | |
| $getData = sanitize_text_field($_GET['my_value']); | |
| $data['attributes']['value'] = [$getData]; | |
| } | |
| return $data; | |
| } | |
| }, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment