I see no problem with it, this is a MyBB snip code:
$form_container->output_row($lang->username_contains, "", $form->generate_text_box('conditions[username]', $input['conditions']['username'], array('id' => 'username')), 'username');
And it outputs this:
<input type="text" name="conditions[username]" value="" class="text_input" id="username" />
And here is the js snip:
<script type="text/javascript" src="../jscripts/autocomplete.js?ver=140"></script>
<script type="text/javascript">
<!--
new autoComplete("username", "../xmlhttp.php?action=get_users", {valueSpan: "username"});
// -->
</script>
Your code seems right to me.
How bizarre, I tried the above code and it still doesn't seem to work.
Ok sorted that problem, cheers
I just got a chance to try Euantor's code for the "Enter Usergroup IDs, seperated by a comma" question:
$groupsToTakeActionOn = explode(',', $mybb->settings['verify_setting1']);
$usersGroups = array_merge($mybb->user['usergroups'], explode(',', $mybb->user['additionalgroups']));
$canDo = true; //set to true initially - if the users has been disallowed at all, it will be changed to false below...
foreach ($usersGroups as $usersGroup)
{
if (in_array($usersGroup, $groupsToTakeActionOn))
{
$canDo = false;
}
}
if (!$canDo)
{
error_no_permission();
}
However i'm getting: Warning [2] array_merge(): Argument #1 is not an array
Any idea how I'd solve that?
Cheers
Try this
$groupsToTakeActionOn = explode(',', $mybb->settings['verify_setting1']);
$usersGroups = explode(',', $mybb->user['additionalgroups']);
array_push($usersGroups, $mybb->user['usergroup']);
$canDo = true; //set to true initially - if the users has been disallowed at all, it will be changed to false below...
foreach ($usersGroups as $usersGroup)
{
if (in_array($usersGroup, $groupsToTakeActionOn))
{
$canDo = false;
}
}
if (!$canDo)
{
error_no_permission();
}
Thanks Limu, works perfectly
Also should I be escaping the users input for this setting:
$my_setting_6 = array(
'sid' => 'NULL',
'name' => 'mysetting_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),
);
as it's text. If so, how would I do that?
Cheers
Use $db->escape_string(); to sanitize text.
Thanks Omar, would this be correct?
$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),
);
$userinput = $db->escape_string($mybb->settings['something_disablefor']);
$db->insert_query('settings', $something_setting_1);
$db->insert_query('settings', $something_setting_2);
$db->insert_query('settings', $something_setting_3);
$db->insert_query('settings', $something_setting_4);
$db->insert_query('settings', $something_setting_5);
$db->insert_query('settings', $user_input);
No, this is right:
/*....*/
'description' => $db->escape_string('Please select whether you want this to appear on the register page.');,
/*....*/
Thanks Omar, I meant would I need to escape the users input (what they enter into the textbox)?
Cheers