MyBB Community Forums

Full Version: Hooks to watch for usergroup change
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

I'm working on a plugin that links Discord, MyBB, and a Garry's Mod server's ranks based off the forum. I tried finding these myself, but I am still pretty new to the MyBB plugin development realm. What hooks should I monitor to make sure I catch any instance of a user's primary group being changed? This would need to include banning, changes through the admin cp, changes through the promotion system, and any other way for it to change.

I apologize for being so broad with the question, but I look forward to your answers!
I think you are looking for the datahandler_user_update hook.

function (&$datahandler)
{
	if(!isset($datahandler->user_update_data['usergroup']))
	{
		return;
	}

	// usergroup is being changed
}
Please note that the usergroup might in fact not being changed, so you might want to verify that yourself.
https://github.com/mybb/mybb/blob/1b2540...s.php#L503