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 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
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;
}