[Plugin: Contact Form DB] Cannot redeclare is_already_submitted
-
Following your instructions in the forum, I’ve created a filter to check against duplicate submissions based upon user name. Here’s the portion of the code that I customized, per instructions:
function my_validate_email($result, $tag) { $formName = 'San Tan - Moonlight Trail (Short) - 2 Nov 2016'; // Change to name of the form containing this field $fieldName = 'your-name-STMoonSTwoNovSixteen'; // Change to your form's unique field name $errorMessage = 'If you are signing up for this hike, you have already previously signed up. If you are requesting to be removed from the hike list, you have already made that request and you will be removed within the next day or so. '; // Change to your error message $name = $tag['name']; if ($name == $fieldName) { if (is_already_submitted($formName, $fieldName, $_POST[$name])) { $result->invalidate($tag, $errorMessage); } }
I have assigned $fieldName a unique name just for the Moonlight trail hike, so the filter won’t kick up an “already registered” message when a user signs up for a different hike. All works perfectly.
Then, I added a second hike into the mix. I used the same code (above), changing the $formName and $fieldName assignments to reflect the new hike information.
IF I deactivate the Moonlight Trail filter and activate the Goldmine filter, Goldmine works great!
If however, I activate both filters, then I receive:
Fatal error: Cannot redeclare is_already_submitted() (previously declared in /home1/suncitya/public_html/wp-content/plugins/add-actions-and-filters/AddActionsAndFilters_Executor.php(80) : eval()’d code:8) in /home1/suncitya/public_html/wp-content/plugins/add-actions-and-filters/AddActionsAndFilters_Executor.php(80) : eval()’d code on line 21
Clearly I’m not allowed to use the same function names more than – which actually makes sense when I think about it.
In the new filter, if I change the name of the function is_already_submitted to is_already_submitted_GoldmineCI2Nov2016, and change the name of the function my_validate_email to my_validate_email_GoldmineCI2Nov16 – so both are unique, things work again.
1. Does this mean I must create a new filter, ensuring both function names are unique, for every hike contact form that I create in order to catch the duplicate submissions per form?
2. Is there a better, more efficient way to catch the duplicate submissions? I could have over 300 individual hike signup forms per year, and am concerned with the potential overhead and performance hit of having hundreds of filters to run through for each submission.
3. Curiosity question – if the filters key off of the $fieldName, and they check against this for every form submission they receive, then why is a $formName required in the filter code?Thanks so much for all your help.
- The topic ‘[Plugin: Contact Form DB] Cannot redeclare is_already_submitted’ is closed to new replies.