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
Bump

Also is there a better hook to use than datahandler_user_validate for validating registrations?

It works fine with registrations but I've found that when editing a user I receive the error message too.

Thanks Smile
(2012-08-22, 11:32 PM)Vernier Wrote: [ -> ]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

Is no that enough? You will need to over-complicate things to update the field if it is left blank. If you still want to do it you can use the admin_config_settings_edit_commit hook for that:
$plugins->add_hook('admin_config_settings_edit_commit', 'my_hook');
function my_hook
{
	global $mybb;
	$sid = (int)$mybb->input['sid'];

	if($mybb->settings['mysetting_disablefor'] == '')
	{
		global $db;

		$db->update_query('settings', array('value' => '0'), "sid='{$sid}'");
	}
}
(2012-08-24, 08:20 AM)Vernier Wrote: [ -> ]Bump

Also is there a better hook to use than datahandler_user_validate for validating registrations?

It works fine with registrations but I've found that when editing a user I receive the error message too.

Thanks Smile

You can do a check inside your function to avoid the validation outside registration:
if(THIS_SCRIPT == 'member.php' && $mybb->input['action'] == 'do_register')
{
...
}

Or you can hook at member_do_register_start and add your datahandler hook there.
Thanks Omar

the check inside the function worked perfectly, however when I use this:

$plugins->add_hook('admin_config_settings_edit_commit', 'my_hook');
function my_hook
{
    global $mybb;
    $sid = (int)$mybb->input['sid'];

    if($mybb->settings['mysetting_disablefor'] == '')
    {
        global $db;

        $db->update_query('settings', array('value' => '0'), "sid='{$sid}'");
    }
}

it doesn't seem to change it back.

I tried changing the hook to global_start temporarily to see if that did the trick and tried replacing echoing out some text in replacement for the query and it echoed out correctly, so it's something with this line:

$db->update_query('settings', array('value' => '0'), "sid='{$sid}'");

Any idea why that could be?

Thanks again Smile
Try this instead:
$db->update_query('settings', array('value' => '0'), "name='mysetting_disablefor'");

You need to debug it with something like die(); using var_dump(); or print_r(); to find the problem.
Thanks - got that working now Smile

One other question, I'm trying to use a variable in the quickreply, how would I do this?

I've tried:
eval("\$myvariable = \"".$templates->get("mytemplate")."\";");

Then in the showthread_quickreply template I've used:
{$myvariable}

but it doesn't seem to work. I've globalised $mybb, $templates & $myvariable and tried this in the showthread_end hook, should I use a different one?

Thanks again Smile
Thanks Smile
I would make use of the showthread_end hook, check if the quickreply ( $quickreply ) will be shown, then do a str_replace(); on it.
Thanks Omar - that's working now.

The only problem is that it's showing outside of the quickreply, please see the image below:

http://i.imm.io/BSdb.png

Thanks Smile
You need to replace a string within the quickreply variable with your code:
$quickreply = str_replace('<!--STRING-->', $yourvar, $quickreply);

Then you place <!--STRING--> in your showthread_quickreply template anywhere you want it.
Pages: 1 2 3 4 5