MyBB Community Forums

Full Version: Adding a custom usergroup permission field
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all [Image: smile.gif]

I'm writing a plugin where i need to insert custom usergroup permissions fields


$plugins->add_hook('admin_formcontainer_end', 'deactivateaccount_edit_group');
$plugins->add_hook('admin_user_groups_edit_commit', 'deactivateaccount_edit_group_do');



function deactivateaccount_edit_group()
{
    global $run_module, $form_container, $lang, $form, $mybb;

    if($run_module == 'user' &&  $form_container->_title == $lang->users_permissions)
    {
      $lang->load("user_suspendaccount");    

        $deactivation_options = array();
        $deactivation_options[] = $form->generate_check_box("candeactivateaccount", 1, $lang->da_can_deactivate, array("checked" => $mybb->input['candeactivateaccount']));
        ....
        $form_container->output_row($lang->da_deactivate, "", "<div class=\"group_settings_bit\">".implode("</div><div class=\"group_settings_bit\">", $deactivation_options)."</div>");
    }
}

function deactivateaccount_edit_group_do()
{
    global $updated_group, $mybb;                          
    $updated_group['candeactivateaccount'] = $mybb->input['candeactivateaccount'];
}

But when i try to uncheck the field i get
1366 - Incorrect integer value: '' for column 'candeactivateaccount' at row 1

so, what did I do wrong?

Thanks for your help!
The value of $mybb->input['candeactivateaccount'] has to be an integer instead of an empty string if the option is unchecked.

Try this:
function deactivateaccount_edit_group_do()
{
    global $updated_group, $mybb;                          
    $updated_group['candeactivateaccount'] = $mybb->get_input('candeactivateaccount', MyBB::INPUT_INT);
}
Thanks man, I was so tired due to the job that I would never find the solution xD