• 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: Limit Form Submission For User Per Page

Limit Form Submission For User Per Page 7 years 4 months ago #37676

Hello!

I've come across a few forum topics teaching how to limit a user so he may only answer a form a certain number of times.

But is there any way to limit the user to answer the form a specific number of times in specific pages where my form shows? I have the same form being recycled in many pages and I wish the users could answer only once per page. Is that possible at all?

I've come across this documentation:

www.rsjoomla.com/support/documentation/r...for-submissions.html

Although it doesn't get to the point I need help with.
// Define the maximum number of submissions.
$max = 5;
 
// Get the current logged in user.
$user = JFactory::getUser();
 
// Get a database connection.
$db   = JFactory::getDbo();
$query   = $db->getQuery(true);
 
// Setup the query.
$query->select('COUNT('.$db->qn('Username').')')
    ->from($db->qn('#__rsform_submissions'))
    ->where($db->qn('FormId').'='.$db->q($formId))
    ->where($db->qn('Username').'='.$db->q($user->get('username')));
    // You can also count by User ID, just replace the above with:
    // ->where($db->qn('UserId').'='.$db->q($user->get('id')));
 
$db->setQuery($query);
$counter = $db->loadResult();
 
if ($counter >= $max){
  $formLayout = 'Sorry, you have reached the maximum number of submissions for this form.';
}

Is there anyway to adapt this to limit only if the form is submitted at the same page?
Last Edit: 7 years 4 months ago by leonvfreire.
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!