You can use WordPress filter hooks and WS Form functions to dynamically update the label of any field or button before a form is rendered.
Example Code
Here is example code for setting the label of the field with ID 321 in form ID 123. Add this code to your theme functions.php file or favorite code snippet plugin.
<?php
// Add filter to change form ID 123 prior to rendering
add_filter('wsf_pre_render_123', 'my_pre_render_123');
// My function for filter wsf_pre_render_123
function my_pre_render_123($form) {
// Get field ID: 321
$field = wsf_form_get_field($form, 321);
// Change the field label
$field->label = 'Your label here';
// Return the form
return $form;
}
Code Breakdown
WordPress Filter
Before WS Form outputs a form, a WordPress filter named wsf_pre_render_{form_id} runs, where {form_id} is your form ID. WS Form provides a form object to this filter that you can modify.
Below is an example of using this filter:
<?php
// Add filter to change form ID 123 prior to rendering
add_filter('wsf_pre_render_123', 'my_pre_render_123');
// My function for filter wsf_pre_render_123
function my_pre_render_123($form) {
// Your code here
}
Getting a Field
To update a field, use wsf_form_get_field($form, $field_id) where $form is the form passed through the filter and $field_id is the ID of the field you want to modify. This function returns the field settings.
Changing the Field Label
To update the label of a field, set the label property of the field object. For example:
<?php
// Add filter to change form ID 123 prior to rendering
add_filter('wsf_pre_render_123', 'my_pre_render_123');
// My function for filter wsf_pre_render_123
function my_pre_render_123($form) {
// Get field ID: 321
$field = wsf_form_get_field($form, 321);
// Change the field label
$field->label = 'Your label here';
// Return the form
return $form;
}