Smart Tags are a great way to dynamically pull and display data within your form. Additionally, custom Smart Tags can be created to extend this functionality much further.
By default, however, Smart Tags will not be processed if placed within option labels for a Checkboxes field.
To process any Smart Tags included within Checkboxes field choices, you can copy the code below into your site.
/**
* Process smart tags inside checkbox choice labels
*
* @param array $field
* @param array $deprecated
* @param array $form_data
* @return array
*/
function wpf_dev_checkbox_choices_process_smarttags( $field, $deprecated, $form_data ) {
foreach ( $field['choices'] as $key => $choice ) {
if ( ! empty( $choice['label'] ) ) {
$field['choices'][ $key ]['label'] = apply_filters( 'wpforms_process_smart_tags', $choice['label'], $form_data );
}
}
return $field;
}
add_filter( 'wpforms_checkbox_field_display', 'wpf_dev_checkbox_choices_process_smarttags', 10, 3 );