How to populate page name (of the first page) in a multi-page form?
I successfully managed to populate field labels with the following function:
add_filter('gform_pre_render_1', 'populate_custom_field_label');
add_filter('gform_pre_validation_1', 'populate_custom_field_label');
add_filter('gform_admin_pre_render_1', 'populate_custom_field_label' );
add_filter('gform_pre_submission_filter_1', 'populate_custom_field_label');
function populate_custom_field_label($form) {
foreach ($form['fields'] as &$field) {
$post_id = get_query_var('training');
if ($field->id == 30) {
if ( $post_id === 329 ) {
$field['label'] = 'Thuisstudie';
}
else {
$field['label'] = 'Training';
}
}
So I think the code should be something similar:
add_filter('gform_pre_render_1', 'populate_page_name');
add_filter('gform_pre_validation_1', 'populate_page_name');
add_filter('gform_admin_pre_render_1', 'populate_page_name' );
add_filter('gform_pre_submission_filter_1', 'populate_page_name');
function populate_page_name {
/*$page = How to get first page???*/
$post_id = get_query_var('training');
if ($page == 1) {
if ( $post_id === 329 ) {
$page['label'] = 'Virtual training';
}
else {
$page['label'] = 'Classroom Training';
}
}
Don’t know how to call/get the first page name. Anyone who can help me?