MyBB Community Forums

Full Version: [Solved] PHP function to get PM count
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I want to improve the PM system a bit by adding the PM count in the Inbox, Sent Items, Drafts and Trash can folders.

OLD:
[Image: j9564nfb.png]
NEW:
[Image: uuppwfna.png]

Any help is greatly appreciated Smile
Use variables
For unread PMs: {$mybb->user['pms_unread']}
For total PMs: {$mybb->user['pms_total']}

I don't know the other variables, I am sorry
Hi, yes those two are defined in the functions_user.php:
	// Update total number of messages.
	if($count_to_update & 1)
	{
		$query = $db->simple_select("privatemessages", "COUNT(pmid) AS pms_total", "uid='".$uid."'");
		$total = $db->fetch_array($query);
		$pmcount['totalpms'] = $total['pms_total'];
	}
	
	// Update number of unread messages.
	if($count_to_update & 2 && $db->field_exists("unreadpms", "users") == true)
	{
		$query = $db->simple_select("privatemessages", "COUNT(pmid) AS pms_unread", "uid='".$uid."' AND status='0' AND folder='1'");
		$unread = $db->fetch_array($query);
		$pmcount['unreadpms'] = $unread['pms_unread'];
	}

I found PM counts in
private.php?action=empty
, but I don't know how to make this work in the usercp navigation. Please any help is greatly appreciated, I need this for my forum.
It is simple, go to the usercp template, you will find the PMs Inbox link there, just beside it type:

{$mybb->user['pms_unread']}

That should do the trick.
No, that's not what I want. I don't want to display the number of unread PMs. I want to display the total number of PMs in those folders, regardless if they are unread or not.

Like, if your Inbox folder contains 3 PMs (unread or read), it should look like this:
Inbox (3)

If your Trash Can contains 4 PMs, it should look like this:
Trash Can (4)

etc.

How can I make this work?
I don't know about trash can, but for the total PMs in Inbox, it is:
{$mybb->user['pms_total']}

Just put it beside the Inbox link in the UserCp template
No, {$mybb->user['pms_total']} sums up the total number in ALL folders. Like if you have 2 PMs in Inbox and 4 PMs in Sent Items folders, then {$mybb->user['pms_total']} will add these numbers and display 6. But that is not what I want Sad
Oh I am sorry then, guess I cannot help you Sad
No problem, thanks for trying Smile

Edit: Thanks to user Plexxart I found the solution: http://forum.mybboard.de/thread-25492-po...#pid170730 Smile