gform_polls_results_ajax_response

Description

Allows the Ajax response to be overridden.

Usage

The following would apply to all forms:

add_filter( 'gform_polls_results_ajax_response', 'your_function_name', 10, 2 );

To target a specific form, append the form id to the hook name. (format: gform_polls_results_ajax_response_FORMID)

add_filter( 'gform_polls_results_ajax_response_1', 'your_function_name', 10, 2 );

Parameters

  • $response array

    An associative array containing the properties to be returned in the Ajax response.

    The properties available in the array are as follows:
    
    canVote bool
    Indicates if the user is allowed to vote.
    
    resultsUI string
    The results HTML, confirmation, or an empty string.
    
  • $form Form Object

    The current form.

Examples

add_filter( 'gform_polls_results_ajax_response', 'change_result', 10, 2 );
function change_result( $response, $form ){
	//change the color of the text of the first question
	$response['resultsUI'] = str_replace('<div class=\'gpoll_field_label\'>', '<div class=\'gpoll_field_label\' style=\'color:red\'>', $response['resultsUI']);
	return $response;
}

Placement

This code should be placed in the functions.php file of your active theme.

Since

This filter was added in the Gravity Forms Polls Add-On version 3.2.2.

Source Code

This filter is located in GFPolls::gpoll_ajax() in gravityformspolls/class-gf-polls.php.