MyBB Community Forums

Full Version: Need some guidance related to custom usertitle - What checks for its errors
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,

Am working over some plugin related to user title. Now, I saw but there was no hook especially for user title, but just for edit profile. I want something here to check when a user enters new user title, for example lets say,

A user is entering a custom usertitle having the letters "example" in it, and I code some links along which I added example as disallowed character in user title, then it should throw an error.

Am using something like:

if($mybb->input['usertitle'] != $mycondition)
// Return error here

But that doesn't seem to work well.

Any ideas? Not sure what to do with these user title input thing.

Any help would be appreciated.

Thank you.
use the validator hook "datahandler_user_validate" in /inc/datahandlers/user.php and simply create a function in your plugin to validate the usertitle contents using preg_match( ) or even a simple stristr( )
Could you give me just a small example? Just need to make sure. Smile
something like this should work, but i have not tested it

$plugins->add_hook("datahandler_user_validate", "myplugin_validate_title");

function myplugin_validate_title(&$this)
    global $mybb;

    $disallowed = explode(",",$mybb->settings['myplugin_disallowed_titles')]

    $usertitle = &$this->data['usertitle'];

    $error = false;
    foreach($disallowed as $search)
        if(stristr($usertitle, $search))
            $error = true;

        $this->set_error('Invalid Characters in User Title', array($user['usertitle']));
        return false;

    return true;
Getting this:

 Call to undefined function functionname()

post up your plugin code
(2011-12-08, 06:31 PM)crazy4cs Wrote: [ -> ]Getting this:

 Call to undefined function functionname()

This shows that you've not edited the plugin info or activate/deactivate functions properly. It should be similar to plugin's file name actually.