"Enter Usergroup IDs, seperated by a comma"
#41
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
[Image: information.gif] MyBB Support Technician
Please do not PM me for support.


MyBBatically - A quick and easy way to update your board!
Reply
#42
(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.
Reply
#43
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
[Image: information.gif] MyBB Support Technician
Please do not PM me for support.


MyBBatically - A quick and easy way to update your board!
Reply
#44
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.
Reply
#45
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
[Image: information.gif] MyBB Support Technician
Please do not PM me for support.


MyBBatically - A quick and easy way to update your board!
Reply
#46
I would make use of the showthread_end hook, check if the quickreply ( $quickreply ) will be shown, then do a str_replace(); on it.
Reply
#47
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
[Image: information.gif] MyBB Support Technician
Please do not PM me for support.


MyBBatically - A quick and easy way to update your board!
Reply
#48
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)