skip to Main Content

I’m trying to figure out a way to differenciate the limit submission for a "shared" form on different pages.

If I activate the built in function "limit submissions" in a form (which is shared on different pages) also the submissions limit is shared.
I try to explain better

  • I have 1 form, with let’s say 50 limited submissions.
  • I use this form on page1, page2, page3
  • 10 users go to page1, and submit the form, and nobody submitted anything on page2 or page3 yet.
    The remaining allowed submissions in page2 and page3 would be 40.

I need to be able to limit submissions according to the specific pages where the form is used, so in this specific case I need to be able to have 40 submissions left on page1, but still 50 left on the other two pages.

Do you have any suggestion on how I can achieve this?
Thanks

2

Answers


  1. I’m not aware of a simple way to accomplish this with code but I do have a plugin that handles submission limits per page.

    https://gravitywiz.com/documentation/gravity-forms-limit-submissions/#embed-url

    Embed URL

    Limit by the URL from which the entry was submitted. This is very useful when using the same form on multiple pages and wanting to apply the Feed Limit per page rather than per form.

    Login or Signup to reply.
  2. You could try adding a hidden field to capture the embed page with the following merge tag in the default value: {embed_url}

    Then add this to your functions.php

    add_filter( 'gform_get_form_filter_100', 'limit_by_embed_page', 10, 2 );//replace 100 with your form id
    function limit_by_embed_page( $form_string, $form ) {
        $page=array("page1","page2","page3");//replace with name of pages where form is embedded
        for($x=0;$x<count($page);$x++){
            $search_criteria[$x] = array(
                'status'        => 'active',
                'field_filters' => array(
                    'mode' => 'all',
                    array(
                        'key'      => '2',
                        'operator' => 'contains',
                        'value'    => $page[$x]
                    )
                )
            );
                
            $entries[$x] = GFAPI::get_entries($form,$search_criteria[$x]);
            $entries_count[$x] = count($entries[$x]);
            if ( $entries_count[$x] > 50 && strpos($_SERVER['REQUEST_URI'], $page[$x]) !== false) {//change 50 to the # of the page limit
                $form_string = '<p>Sorry, the submission limit for this  has been reached.</p>';
            }
        }   
        return $form_string;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search