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

Complete Uninstall to Work in J4??
We have recently updated a site from Joomlav3 to v4 (4.4.2). Now when we go to m...
2 Replies
Posted on Tuesday, 30 April 2024
  • New
  • verschiedene URL's für Kursübersicht einer Kategor
    Hallo, ich habe eine Frage in Bezug auf SEO: ein externer Spezialist macht die...
    1 Replies
    Posted on Monday, 29 April 2024
  • New
  • Google no index für bestimmte Seiten/Details
    Hallo ich habe eine kleine Frage: wo kann ich einstellen, dass Google die Seite...
    1 Replies
    Posted on Wednesday, 24 April 2024
  • New
  • Changes to Submission Form?
    Are you able to make changes to the Hotspot submission form? There are several f...
    0 Replies
    Posted on Friday, 26 April 2024
  • New
  • Question regarding custom fields
    How do I access custom fields after I have created them?...
    0 Replies
    Posted on Wednesday, 24 April 2024
  • New
    • #custom fields