Display Poll Results When Limit Is Reached

Instructions

Read the Walkthrough

Code

Filename: gpls-show-poll-results.php

<?php
/**
 * Gravity Perks // GP Limit Submissions // Display Poll Results When Limit Is Reached
 * https://gravitywiz.com/documentaiton/gravity-forms-limit-submissions/
 *
 * Instruction Video: https://www.loom.com/share/df98fa2dda97424495eb1757a772f6d0
 *
 */
add_action( 'gform_get_form_filter', function( $markup, $form ) {

	if ( ! is_callable( 'gf_polls' ) || ! gf_polls()->get_form_setting( $form, 'displayResults' ) ) {
		return $markup;
	}

	if ( is_callable( 'gp_limit_submissions' ) && property_exists( gp_limit_submissions(), 'enforce' ) && gp_limit_submissions()->enforce->is_limit_reached() ) {
		add_filter( "gform_get_form_filter_{$form['id']}", function( $markup, $form ) {
			$results = gf_polls()->gpoll_get_results( $form['id'] );
			$markup .= $results['summary'];
			return $markup;
		}, 11, 2 );
	}

	return $markup;
}, 10, 2 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.