i have created a custom function for pre_render to check the user id entries and if user has already submitted a form then to show a message.
Locally i have this working but when on wpengine server page back after the form is submitted the function doesnt fire as it looks like the page back has returned to a prev page state and not reloaded the page.
Does any one know if gravity forms can force a page reload when returning to a form with browser back?
Heres my function
add_filter('gform_pre_render', 'pre_submission_duplication_check');
function pre_submission_duplication_check($form)
{
if (is_user_logged_in()) {
$current_user = wp_get_current_user(); //The curent user
$search_criteria = array(
'status' => 'active', //Active forms
'field_filters' => array( //which fields to search
array(
'key' => 'created_by', 'value' => $current_user->ID,
)
)
);
$form_id = 3;
$entry_count = GFAPI::count_entries($form_id, $search_criteria);
if ($entry_count >= "1") { // If they have submitted the form: ?>
<div class="form-duplication-message">
<h2>you have already submitted a form</h2>
<p class="message-sub">please continue</p>
<?php
$continue = get_field('continue', 'option');
$next = getPrevOrNextScreenLink(false, $continue, 'arrow-right');
if ($next) {
echo $next;
}
?>
</div>
<?php
return;
} else {
return $form;
}
}
}
}