Created
September 13, 2016 21:03
-
-
Save jaredatch/426b9796f2e0dfd8305adad286b56ae5 to your computer and use it in GitHub Desktop.
WPForms set select fields use raw values (if configured) instead of field label
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 | |
| /** | |
| * Set the field value to the raw value instead of the field label. | |
| */ | |
| function wpf_select_use_raw_values( $fields, $entry, $form_data ) { | |
| foreach( $fields as $id => $field ) { | |
| // Only do this for select fields that are configured to use raw values | |
| if ( 'select' == $field['type'] && isset( $form_data['fields'][$id]['show_values'] ) ) { | |
| $fields[$id]['value'] = $fields[$id]['value_raw']; | |
| } | |
| } | |
| return $fields; | |
| } | |
| add_filter( 'wpforms_process_filter', 'wpf_select_use_raw_values', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment