Description
The gform_form_pre_results filter allows developers to modify the Form object prior to calculating the results in the results admin page. The results page is currently only used by add-ons that implement the Add-On Framework.
Usage
add_filter( 'gform_form_pre_results', 'your_function_name' );
You can also target a specific form by adding the form id after the hook name. (format: gform_form_pre_results_FORMID)
add_filter( 'gform_form_pre_results_10', 'your_function_name' );
Parameters
| Parameter | Type | Description |
|---|---|---|
$form | array | The form object. |
Examples
Add the field id to the field labels.
add_filter( 'gform_form_pre_results', 'modify_results_fields' );
function modify_results_fields( $form ) {
foreach ( $form['fields'] as &$field ) {
$field['label'] .= sprintf( " (Field ID: %d)", $field['id'] );
}
return $form;
}
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Source Code
apply_filters( "gform_form_pre_results_$form_id", apply_filters( 'gform_form_pre_results', $form ) );
This filter is located in GFResults::results_page() and GFResults::ajax_get_results() in includes/addon/class-gf-results.php.