• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Restricting number of Form Submissions Basis Time

Restricting number of Form Submissions Basis Time 10 years 5 months ago #29636

  • modiac
  • modiac's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
Hello,

I need advise wherein attempting to restrict number of Submissions basis User Id in 24 hours
Have Modified the code given in as below by adding Time Clause too

Thus if a user meets both conditions
> 5 submissions and under 24 hours

he should get a message of maximum submissions reached for the day


Using - Script called on form display
Example Script - www.rsjoomla.com/support/view-article/95...ns-per-username.html


$max = 5;
$user = JFactory::getUser();
$db = JFactory::getDbo();
$query = $db->getQuery(true);

// Setup the query.
$query->select('COUNT('.$db->qn('UserId').')')
->from($db->qn('#__rsform_submissions'))
->where($db->qn('FormId').'='.$db->q($formId))
// Added Time String
->where($db->qn('DateSubmitted').'>='.$db->q('DATE_SUB(NOW(), INTERVAL 1 DAY)'))

->where($db->qn('UserId').'='.$db->q($user->get('id')));

$db->setQuery($query);
$counter = $db->loadResult();

if ($counter >= $max){
$formLayout = '<p style="color:red;">Sorry, you have reached the maximum number of submissions for this form</p>';
}

But above is not executing
Can some one help on adding Time Clause to it.
Last Edit: 10 years 5 months ago by modiac.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!