I modified /admin/doclearcache.php with some extra cleanup code, including resetting PM counters.

just before the line:
PHP Code
$userob->clear_cached_perms(); 

I added just before that:

PHP Code
// set all PM counters to zero.
$query = "
		update	{$config['TABLE_PREFIX']}USER_PROFILE
		set	USER_TOTAL_PM=0,
			USER_PM_TOTALS=0
";
$sth = $dbh->do_query($query,__LINE__,__FILE__);

// cycle through all user ID's that have New PM's.

$query = "
	SELECT count(*) AS count, t1.USER_ID
	FROM {$config['TABLE_PREFIX']}PRIVATE_MESSAGE_USERS AS t1, 
		  {$config['TABLE_PREFIX']}PRIVATE_MESSAGE_TOPICS AS t2
	WHERE t1.TOPIC_ID = t2.TOPIC_ID
	AND   t2.TOPIC_LAST_REPLY_TIME > t1.MESSAGE_LAST_READ
	GROUP BY t1.USER_ID
";

$sti = $dbh->do_query($query,__LINE__,__FILE__);
while (list($total_unread,$PM_UserId) = $dbh -> fetch_array($sti)) {
	$query = "
		update	{$config['TABLE_PREFIX']}USER_PROFILE
		set	USER_TOTAL_PM = ?
		where	USER_ID = ?
	";
	$dbh->do_placeholder_query($query,array($total_unread,$PM_UserId),__LINE__,__FILE__);	
}

$query = "
	SELECT count( USER_ID ) AS cnt,USER_ID
	FROM ubbt_PRIVATE_MESSAGE_USERS
	GROUP BY USER_ID
";
$sti = $dbh->do_query($query,__LINE__,__FILE__);
while (list($total_PM,$PM_UserId) = $dbh -> fetch_array($sti)) {
	$query = "
		update	{$config['TABLE_PREFIX']}USER_PROFILE
		set	USER_PM_TOTALS = ?
		where	USER_ID = ?
	";
	$dbh->do_placeholder_query($query,array($total_PM,$PM_UserId),__LINE__,__FILE__);	
}
 

This will reset all PM counts, and new PM counts if you do a clear cache.


[Linked Image from siemons.org]