PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

limit entries per day and user

  1. bloew11
    Member

    hello,

    i know the possibility to limit entries. but is there also a possibility to limit per day and user?

    for example: user A can only create 2 entries per day

    Thanks,
    Beat

    Posted 13 years ago on Wednesday February 9, 2011 | Permalink
  2. Currently it is not a built in feature to limit entries per day and user.

    If you want to limit entries per user you could do this by limiting it by email... add an email field to your form if you don't already have one and then edit that field and set the Rules so No Duplicates is checked.

    What this will do is make it so that the email address can only be used once when submitting the form. If they try using the same email address again it will be invalid. It isn't full proof because they could use a different email, but for contest entries, etc. it should be fine.

    Posted 13 years ago on Wednesday February 9, 2011 | Permalink
  3. bloew11
    Member

    Hi Carl,

    thansk for your answet. okay so i have to think about another solution:) because i want 2 posts per day. but i will find a solution with my developer.

    thank you!

    beat

    Posted 13 years ago on Wednesday February 9, 2011 | Permalink
  4. It would be possible to use a validation hook that exists to write custom code to write custom validation yourself. So if your developer is good at PHP and WordPress development, he could do this. If you need details on which hook to use, let us know. It's the gform_validation hook. We can provide example code for using this hook.

    Posted 13 years ago on Wednesday February 9, 2011 | Permalink
  5. We really need this feature and have a fabulous developer. Can we get the example code for the hook?

    Posted 13 years ago on Wednesday March 2, 2011 | Permalink
  6. The hook you would use to do custom validation would be the gform_validation hook.

    Here is an example of using the gform_validation hook:

    <?php
    add_filter('gform_validation', 'custom_validation');
    function custom_validation($validation_result){
    
    // set the form validation to false
    $validation_result["is_valid"] = false;
    $form = $validation_result["form"];
    
    // specify the first field to be invalid and provide custom validation message
    $form["fields"][0]["failed_validation"] = true;
    $form["fields"][0]["validation_message"] = "This field is invalid!";
    
    // update the form in the validation result with the form object you modified
    $validation_result["form"] = $form;
    
    return $validation_result;
    }
    ?>

    This example would apply this custom validation to ALL forms. If you wanted to apply the custom validation to only a specific form you would change the following.

    Change:

    add_filter('gform_validation', 'custom_validation');

    To:

    add_filter('gform_validation_ID', 'custom_validation');

    You would place the form id you want to change where the _ID is in the example above. So if you wanted to apply the custom validation to only form id 5 that line of code would look like:

    add_filter('gform_validation_5', 'custom_validation');

    Posted 13 years ago on Wednesday March 2, 2011 | Permalink