How to limit form submission per user per day and week? The goal is very straightforward. I need a form to limit each user to 1 submission per day and 3 per week.

What I found:

Webform:
The "Form settings" in webform has the "Per user submission limit" setting. It does not allow me to make more than 1 validation. I'm not able to have both per day and per week in the same form.

Entityform:
I found people use hook function on node limit on Drupal 8. This may work on Drupal 7 Entityform but I don't know how to write that syntax.

Rule:
It may possible to use Rule module but I don't see any connection with period of time validation.

//////
PS: My question is about the limit on Webform(or Entityform) submission for authenticated users.
Make a custom module to implement hook_node_access, i will post some code based on a user date field that compares 'today' with this user-date-field and return access deny if dates comparison goes beyond 'today', and another with today+7 days, you will have to adapt this code to your needs; please add in user profile a date field, this field it has to be updated by rules every time a user adds content of your 'special content-type', maybe you will need 2 user-date-fiels, one for each 'special-contentype' if you need help with this last comment please ask.

// replace HOOK with yourmodulename and field machine names 
function HOOK_node_access($node, $op, $account) {

  $type = is_string($node) ? $node : $node-&gt;type;

  global $user;

  // check if not anonymous
  if($user-&gt;uid!=0){

    //check if not administrator role, admin will have allways access
    $user_role = '';
    if (in_array('administrator', $user-&gt;roles)) {
      // do fancy stuff
      $user_role = 'administrator';
    }

    if (!$user_role == 'administrator') { 

      $user_logged = user_load($user-&gt;uid);
      $user_date_field = $user_logged-&gt;YOUR_USER_DATE_FIELD[LANGUAGE_NONE][0]['value'];

      // today date in UNIX date stamp
      $today_int = date('U');

      // your user_date_field in UNIX time stamp
      $date_int = (int)strtotime($user_date_field);

      // check if 'today' is &gt; than user_date_field
      $diff = $date_int - $today_int;
      $diff = round($diff/86400); // diff in days betwen 2 dates

      // today comparison
      if ($diff &gt;= 0 ) {
        // code... user do have access to add/edit content


      } else {
        // code... retunr access deny 'today' add/edit 
        if ($type == 'YOUR_CONTENT_TYPE_MACHINE_NAME') {
          // if options are update ore cerate content, return access deny
          if ($op == 'update' OR $op == 'create') {
            return NODE_ACCESS_DENY;

          }
        }
      }

      //  1 week comparison
      $diff7 = $diff + 7;

      if ($diff7 &gt;= 0 ) {
        // code... user do have access to add/edit content

      } else {
        // code... retunr access deny 'today +7 days' add/edit
        if ($type == 'YOUR_CONTENT_TYPE_MACHINE_NAME_7') {
          // if options are update ore cerate content, return access deny
          if ($op == 'update' OR $op == 'create') {
            return NODE_ACCESS_DENY;

          }
        }
      }
    }
 }
}


NOTE, if you do not want to add fields to user profile form, it could be done by adding variables to logged-user by HOOK_entity_property_info_alter(&amp;$info), if this is needed please ask.

EDIT:

please specyfy in your question that is about webforms, so, above code do not apply, i'll leave it, could be usefull for someone else.

what you can do is still keep 'user_date_field', install the following mudules: flags, rules and panels.

I will explain only ‘today’ settings, same thing for ‘1 week settings’, only in this last case you will need another field (or user-variable) to store how many webforms has submitted this user in current week.

Steps:

• enable rules, rules scheduler, flag &amp; panels modules.

• make a user flag ‘user-posted-a-webform’

• in rules: 

• make a component, unflag current user (it will be invoked later).

• make a rule, flag user when submit a webform, update 'user_date_field' with site-current-date

• in panels make a page and add your webform, add a rule (inside panles content section) make it visible only if user is NOT flagged.

• Return to your rule, add an action “schedule component evaluation”, choose your component, inside action setting, on ‘scheduled evaluation date’ enter ‘+1 day’.

• Done


COMPONENT unflag-user