1. Chris Zurlinden
  2. Newbies area
  3. Tuesday, 06 October 2009
  4.  Subscribe via email
i would like to count all comments a user made

Thats why i hacked your code a bit.
First i had to add a field jos_users.comments

then in comment.class.php i added the following
[CODE]
function setUser()
{
$database =& JFactory::getDBO();

/* also in post ! and notification */
$query = "SELECT * FROM jos_users WHERE id='".$this->_userid."' LIMIT 1";
$database->SetQuery($query);
$result = $database->loadAssocList();
if ($result) {
$user = $result[0];
$this->_usertype = $user['usertype'];
$this->_tname = $this->_use_name ? $user['name'] : $user['username'];
$this->_temail = $user['email'];
$this->_tcomments = $user['comments'];# added by zurli
}

}
[/CODE]

and then more below i changed this
[CODE]
#Commentscounter edit by zurli
$this->_tcomments = $this->_tcomments+1;
$query = "
UPDATE jos_users SET
comments=$this->_tcomments
WHERE id=$userid";
$database->SetQuery($query);
$database->Query() or die(_JOOMLACOMMENT_EDITINGFAILED . "\n $query";);
#End Commentscounter edit by zurli

$database->SetQuery("
INSERT INTO jos_comment
(contentid,component,ip,userid,usertype,date,name,email,website,notify,title,comment,published,voting_yes,voting_no,parentid)
VALUES(
'$this->_content_id',
'$com',
'$ip',
'$userid',
'',
'$createdate',
'$name',
'$email',
'$website',
'$notify',
'$title',
'$comment',
'$published',
'0',
'0',
'$parent_id'
)";);
$result=$database->Query() or die(_JOOMLACOMMENT_SAVINGFAILED); //.$database->getQuery());

[/CODE]

what you think about solution
Responses (6)


There are %s replies to this question. If you want to see them you need a valid subscription.
If you have a valid subscription, please login now.
Visit store now

Last questions

Anzeige von mehrtägigen Events auf Buchungsseite
We have been using Matukio for quite some time now. Unfortunately, we have been ...
5 Replies
Posted on Sunday, 03 August 2025
  • Resolved
  • Is Ccomment still alive?
    Is Ccomment still being supported? It's time for my Pro renewal but I haven't se...
    2 Replies
    Posted on Thursday, 14 August 2025
  • Resolved
  • Assistance Needed – Error When Posting Comments
    Hello, I’m experiencing an issue when trying to submit a comment on my site u...
    0 Replies
    Posted on Sunday, 10 August 2025
    Hotspots Pro 6.0.13 compatability with Joomla 5.3.
    Running Hotspots Pro 6.0.13 on Joomla 4.4.13 and want to upgrade to Joomla 5.3.1...
    2 Replies
    Posted on Friday, 04 July 2025
    some questions on Hotspots
    Hi, On Hotspots extension : 1) is it possible to add our own map layer / v...
    0 Replies
    Posted on Thursday, 03 July 2025