• 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.

Viewing 1 replies (of 1 total)
  • Thread Starter scamrwordpressadmin

    (@scamrwordpressadmin)

    Hello,

    Just checking in to see if anyone else has run into this? It appears that in order to check for duplicate submissions by user name (some members share email so they aren’t unique), I need to do the following:

    1. Create a unique form for each hike a user might sign up for. That form must have a unique user name specific to that hike & form.
    2. Create a unique filter for each hike that searches for that unique user name created in step #1.

    We also need to allow users to unsubscribe to a hike, so I need to:

    Redo steps 1 & 2 above for the unsubscribe action, creating new filters & unique field/form/function names for each.

    We could have upwards of 300 hikes in a year – which means I’ll have 600 forms and 600 filters in a year. That’s a lot of coding! And, won’t make this site easy to hand off should someone else take over maintenance later on.

    1. What impact will all these filters have on the performance of the site?

    and more importantly

    2. Is there a better way that I should be doing this? (catching dup submissions for sign up and unsubscribe for approx 300 individual hikes).

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Contact Form DB] Cannot redeclare is_already_submitted’ is closed to new replies.