Short question about plugin settings
#1
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
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM
Reply
#2
if($mybb->get_input('settingname') == "something")
{
$mybb->input['settingname'] = "somethingelse";
}
Reply
#3
Ok, thanks.

I'll try soon, but can you confirm me that admin_config_settings_change_commit is the good hook ?
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM
Reply
#4
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

(02-25-2015, 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.
Reply
#5
(02-25-2015, 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.

(02-25-2015, 03:13 PM)Destroy666 Wrote:
(02-25-2015, 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/
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)