MyBB Community Forums

Full Version: Custom registration validation hook
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I want to put a custom validation when a user registers.

I saw a lot of hooks, for example member_do_register_start getting information with $mybb->input and populating $errors, but this variable is overwritten a few lines later.

I need to validate username and email, but verify_username(), verify_username_exists() and verify_email() don't have hooks.

Another one is datahandler_user_insert but I can't add/show my error(s).

Ideas?
datahandler_user_validate?
(2016-01-30, 11:37 PM)Destroy666 Wrote: [ -> ]datahandler_user_validate?

I saw it, with global $user I can access user information, but how can I add my error? These are the lines after the hook and I can't access $this variable from my plugin function (with $this, maybe I could use $this->set_error() or something else)

$plugins->run_hooks("datahandler_user_validate", $this);

// We are done validating, return.
$this->set_validated(true);
if(count($this->get_errors()) > 0)
{
        return false;
}
else
{
        return true;
}
As you can see, $this is passed as a parameter. Read that parameter by reference in your hook.
Awesome, thanks!