MyBB Community Forums
Add hooks where post counters are updated. - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Development (https://community.mybb.com/forum-161.html)
+--- Forum: Suggestions and Feedback (https://community.mybb.com/forum-199.html)
+--- Thread: Add hooks where post counters are updated. (/thread-221692.html)



Add hooks where post counters are updated. - Omar G. - 2019-01-27

I'm coding a plugin that needs to recount posts, but apparently not all places where counting occurs have hooks. The following code should add one hook. File /admin/modules/user/users.php.
while($user = $db->fetch_array($query))
{
	// Protect Super Admins
	if(is_super_admin($user['uid']) && !is_super_admin($mybb->user['uid']))
	{
		continue;
	}

	$return_array = delete_user_posts($user['uid'], $date); // Delete user posts, and grab a list of threads to delete
	if($return_array && is_array($return_array))
	{
		$prune_array = array_merge_recursive($prune_array, $return_array);
	}
}



RE: Add hooks where post counters are updated. - Omar G. - 2019-01-27

Why does update_user_counters() lacks a hook? I think it would be helpful.


RE: Add hooks where post counters are updated. - Euan T - 2019-01-27

I'm not opposed to adding hooks, please open a PR with suggested hooks where they'd be helpful Smile