MyBB Community Forums

Full Version: Looking for a hook
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Maybe I've missed it, but I need a hook in the ACP that will fire a function (in my plugin) when the user changes a radio choice.

Or maybe there's a more elegant way? I'm giving the user a choice of which of two places the output of the plugin will appear, by inserting a class in the template. If the user changes the choice in Settings, I have to remove the existing change. Is there already some mechanism for that? (Yes, I know it works in installing and uninstalling the plugin - I need to execute a function to do the changes when the user changes the setting in the plugin. Maybe I've just been working too hard to see some obvious way of doing it.)
Yikes, templates. There's usually always a way to avoid template changes.

Either way, what do you mean you need to hook the ACP? If your settings are that complex, you could just create your own module.
Actually, the hook is pretty simple Toungue
admin_user_users_edit_commit is one of them, but there are a couple of commit hooks.

Here's a basic example using the above named hook.
function some_func_users_admin_commit()
{
	global $mybb, $db;
	
	$newdata = array("some_db_field" => $mybb->input['some_input']);
	
	$db->update_query("users", $newdata, "uid='".intval($mybb->input['uid'])."'");
}
Thanks, Dylan - I hooked admin_config_settings_change_commit for the change.

@Revenger:
If you want your output to appear on an existing page, you have to add it to the template. If you want to add it to one of two (or more) places, you have to replace the original change when the admin changes the placement.

Once I found the hook (and stopped clobbering the core code), it was trivial.

Now - on another topic (yeah, I know), I need a "create an account for this user with this password" hook. I know I can hook the start or end of the registration process, but can I give some core code or hook the username and password (and maybe more data) and have it create the registration? As a bonus, can I tell it to bypass the settings and just create and validate the registration, regardless of the normal registration settings? (Without this, an LDAP plugin is almost worthless.) It's not a security hole - if someone hacked the LDAP server, no one is going to be worrying about MyBB - they'll be worrying whether their CV is up to date, as far as flipping hamburgers.