MyBB Community Forums

Full Version: Short question about plugin settings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello there,

I'm working on a new plugin and have a some small question:

I want to check if the settings have changed when the admin saves the plugin configuration, and warn him if there are troubles with the new settings.

I thing I've to use the admin_config_settings_change_commit hook to get the new values and compare them with $mybb->settings. But How to block the recording and warn ?

And can I simply redirect the admin to the plugin' settings page after plugin activation ?

Regards,
CrazyCat
if($mybb->get_input('settingname') == "something")
{
$mybb->input['settingname'] = "somethingelse";
}
Ok, thanks.

I'll try soon, but can you confirm me that admin_config_settings_change_commit is the good hook ?
Yes. You should rather use $mybb->input['upsetting']['settingname'] for the new setting value though (not sure if it works without ['upsetting'] too, but I doubt). Example: https://github.com/mybb/mybb/blob/featur...s.php#L996

(2015-02-25, 08:08 AM)Crazycat Wrote: [ -> ]And can I simply redirect the admin to the plugin' settings page after plugin activation ?

You'll have to get the setting group ID with a query and then build an admin_redirect() link based on it.
(2015-02-25, 03:13 PM)Destroy666 Wrote: [ -> ]Yes. You should rather use $mybb->input['upsetting']['settingname'] for the new setting value though (not sure if it works without ['upsetting'] too, but I doubt). Example: https://github.com/mybb/mybb/blob/featur...s.php#L996

Thanks, I'll look that.

(2015-02-25, 03:13 PM)Destroy666 Wrote: [ -> ]
(2015-02-25, 08:08 AM)Crazycat Wrote: [ -> ]And can I simply redirect the admin to the plugin' settings page after plugin activation ?

You'll have to get the setting group ID with a query and then build an admin_redirect() link based on it.

That's what I did, so I used the better way \o/