MyBB Community Forums

Full Version: "Enter Usergroup IDs, seperated by a comma"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
You only need to sanitize your settings when inserting. There is no much you can do about what users insert when editing those settings from the ACP, MyBB already sanitizes it there. Line #524~
Oh I didn't realised it sanitized it, I thought we had to do that Toungue

Also if the user doesn't input any data into this setting:
$something_setting_6 = array(
        'sid'            => 'NULL',
        'name'        => 'something_disablefor',
        'title'            => 'disable for (1,2)?',
        'description'    => 'Please select whether you want this to appear on the register page.',
        'optionscode'    => 'text',
        'value'        => '0',
        'disporder'        => 6,
        'gid'            => intval($gid),

How can I save the setting with the value of 0 automatically as if they remove the 0, it saves blank which doesn't work.

Thanks Smile
Just do something like:
if($mybb->settings['mysetting'] == '') // user left the field empty when editing settings
$mybb->settings['mysetting'] = "0";

Within your function.
Thanks Omar, which function should I place it in? I've tried it in the _newreply_end() function but it doesn't seem to change the setting when I've left it blank.

Thanks Smile
Inside your function.
Thanks for the reply

Does it matter which function I add it in? It doesn't appear to change the value to 0 if i've left it blank.
You can as well add it to he beginning of your plugin file, set $mybb as a global first.
Thanks for the reply

I've added it like this:

    die("You Cannot Access This File Directly. Please Make Sure IN_MYBB Is Defined.");
global $mybb;
if($mybb->settings['mysetting_disablefor'] == '') // user left the field empty when editing settings
$mybb->settings['mysetting_disablefor'] = "0";

require_once MYBB_ROOT."inc/functions_user.php";
// Hooks

but it still doesn't seem to change the setting to 0 when I leave it blank.

Thanks Smile
It will not, but you can now, for example, put {$mybb->settings['mysetting_disablefor']} in your footer template, and if you leave the setting empty it will output "0".
Thanks Omar

How would I go about automatically changing the setting value to 0 if it's left blank as currently it just outputs 0 in the footer.

Thanks Smile
Pages: 1 2 3 4 5