Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created September 13, 2016 21:03
Show Gist options
  • Select an option

  • Save jaredatch/426b9796f2e0dfd8305adad286b56ae5 to your computer and use it in GitHub Desktop.

Select an option

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
<?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