Anyone can provide a snippet on how to get the total posts and joined date of a user? This is not for forum, just infomation I would like to know about the users on my sites. I tried searching around but can't find anything... Thanks

Comments

eliza411’s picture

This is something you can do with the views module. There's also a snippet you might be able to modify for your purposes referenced here: http://drupal.org/node/197419

firebee’s picture

I got the below and it works!

$posts = db_result(db_query("SELECT COUNT(nid) FROM {node} n WHERE uid = %d", $uid));
Total posts: print $posts

$comments = db_result(db_query("SELECT COUNT(cid) FROM {comments} c WHERE uid = %d", $uid));
Total comments: print $comments

$account_created = db_result(db_query("SELECT created FROM {users} WHERE uid = %d", $uid));
$time = check_plain($account_created);
Date joined: print format_date($time, 'custom', 'F j, Y' );

radiofranky2009’s picture

Hi,
$posts works great. is there a way to display the nodes that this user has posted?

thanks