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

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
  • New
  • 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
  • New
  • Trying to resize the image in the comments
    Hey everyone, Basically I am trying to make the images in the comments smalle...
    9 Replies
    Posted on Wednesday, 12 August 2009
    J5 compatibility for Hotspots
    Hi guys, Just started to update my old J3x website. Is there J5 compatibility p...
    2 Replies
    Posted on Monday, 24 February 2025
    • #Hotspots
    • #hotspots Joomla 5
    error message when adding/cofiguring email address
    When configuring the email plugin that send a email message to admin when a new ...
    0 Replies
    Posted on Friday, 09 May 2025