• 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: Display count of user submissions using php

Display count of user submissions using php 9 years 7 months ago #28590

How can I display a count of user submissions using php?

Here is what I have and it is not working.
<?php
$user = JFactory::getUser();
$db = JFactory::getDBO();
 
$query = "SELECT * from #__rsform_submissions where UserId = '.$user' ";
$db->setQuery($query);
$db->query();
$total = $db->getNumRows();
echo $total;
?>

Any help would be greatly appreciated.
The administrator has disabled public write access.

Display count of user submissions using php 9 years 7 months ago #28591

I solved it myself. Below is my solution:
<?php
$db = JFactory::getDbo();
$user = JFactory::getUser();
 
$db->setQuery("SELECT COUNT(*) FROM #__rsform_submissions WHERE `UserId`='". $user->get('id')."'");
$submissions = $db->loadResult();
echo $submissions;
?>
The administrator has disabled public write access.

Display count of user submissions using php 9 years 7 months ago #28601

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
Keep in mind that the script you provided will count all submission made by the user regardless of the form. If you want to count only for a certain form, you should use the following query:
$db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE `UserId`='". $user->get('id')."' AND `FormId`='".(int) $formId."'");
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.
The following user(s) said Thank You: phonroth701
  • 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!