1 (edited by newneo 2004-12-27 14:39)

Topic: Count users posts

I'm posting here something for people as me who wants to have the real counter of user_posts

When you delete a post or a topic the field num_posts of posters isn't decreased. That's a choice of Rickard but I post here the modification if someone wants them

For this you have to modify the file includes/functions.php
in function delete_topic

while ($row = $db->fetch_row($result)){
    $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0];

by

    while ($row = $db->fetch_row($result)){
        $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0];

    $db->query('UPDATE pun_users SET num_posts=num_posts-1 WHERE id='.$row[1]) 
or error('Unable to update users posts', __FILE__, __LINE__, $db->error());
    }

in the function delete_post

just before deleting the post
   

  // Delete the post

add those lines


    //keep the id_poster
    $result = $db->query('SELECT poster_id FROM pun_posts WHERE id='.$post_id.' ORDER BY id DESC LIMIT 2') 
or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
    $row = $db->fetch_row($result);
    $db->query('UPDATE pun_users SET num_posts=num_posts-1 WHERE id='.$row[0])
 or error('Unable  to update users posts', __FILE__, __LINE__, $db->error());

Tell me back want do you think of this modification and if that's usefull for you too

Re: Count users posts

I would be VERY useful for me, but I'm not sure for what version is... I'm running 1.1.5 and can't find these lines in include/functions.php

Could yo tell me if it was made for 1.2 ?

Thanks a lot