Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Abul Khoyer

    (@hellokhoyer)

    Hello @mika85,

    The hook referred in the snippet is deprecated. You would need to replace the hook. Please try with the following snippet,

    add_filter("fluentform/validate_input_item_input_email", function ($error, $field, $formData, $fields, $form) { 
    
    $my_form_id = 1; // Replace with your Form ID
    $max_entries = 25; // Replace with max number of allowed entries
    
    if ($form->id != $my_form_id) {
        return $error;
    }
    
    $email = $formData['email']; // This is the name of your email field
    
    if (empty($email)) {
        return $error;
    }
    
    $max_entries = $max_entries + 1;
    
    $formApi = fluentFormApi("forms")->entryInstance($formId = $my_form_id);
    $atts = [
        "per_page" => $max_entries,
        "search" => $email,
        "sort_by" => "DESC",
        "entry_type" => "all",
    ];
    
    $entries = $formApi->entries($atts, $includeFormats = false);
    
    if( $entries['total'] >= $max_entries){
        return ['You have reached the entry limit'];
    }
    
    return $error;
    
    },10,5);

    Please make sure you have mapped the form ID and email field correctly according to yours.

    Thank you.

    Thread Starter mika85

    (@mika85)

    Thanks for your response Abul but this code doesn’t work either.

    However, I entered the correct form number as well as the maximum number of entries and checked if my email field is correctly configured with the ’email’ identifier and it does not work.

    On the other hand, this creates a conflict for me and no form goes through with any email address.

    Have you tested on your side to see if the code you gave me works on your side?
    Thank you anyway for your help.

    Sincerely
    Mikael

    Plugin Support Abul Khoyer

    (@hellokhoyer)

    Hello @mika85,

    It seems something went wrong there. Can you please open a ticket on our business portal so we can check further.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Limit number of entries per email address’ is closed to new replies.