Not Solved Need help with add_hook
#1
Not Solved
How to add a hook to quick reply please?

$plugins->add_hook("datahandler_post_validate_post", "wordfilter");
$plugins->add_hook("datahandler_post_validate_thread", "wordfilter");
Reply
#2
Not Solved
http://docs.mybb.com/MyBB_Plugin_Hooks.html - there is no specific hook for quick reply. You can try modifying it by hooking to showthread_end though. But I'm not sure what you exactly mean and need.
Reply
#3
Not Solved
Actually, you can hook to newreply_do_newreply_end and check for $mybb->input['ajax']: if present, the post was made via the quick reply box.
[Image: fSGNVQj.png]
Reply
#4
Not Solved
I have created a simple plugin to block URLs but for some reason error message doesn't show when posting through quick reply help me to fix this issue?

if(preg_match($regex, $post->data['message'], $match))
    {
        $post->errors['urlfilter']['error_code'] = "Your post has triggered our moderation system!<br/> Please make sure you are not posting any URL as you YET can't post any!<br/> Also check for any grammar errors!";
    }
Reply
#5
Not Solved
@shade:
Can't it be done with this?
if($mybb->input['method'] == "quickreply")
{
	// Do something ...
}
Reply
#6
Not Solved
(2014-01-06, 10:38 PM)marcus123 Wrote: I have created a simple plugin to block URLs but for some reason error message doesn't show when posting through quick reply help me to fix this issue?

if(preg_match($regex, $post->data['message'], $match))
    {
        $post->errors['urlfilter']['error_code'] = "Your post has triggered our moderation system!<br/> Please make sure you are not posting any URL as you YET can't post any!<br/> Also check for any grammar errors!";
    }

The post datahandler has already validated your post at newreply_do_newreply_end. You will need to hook @ datahandler_post_validate_post instead and set an error like this:

$this->set_error("Your post has triggered our moderation system!<br/> Please make sure you are not posting any URL as you YET can't post any!<br/> Also check for any grammar errors!");

Or using an error code of your own and add a language variable in newreply.lang.php.

Strip off that $match variable also. You don't need it.

(2014-01-06, 11:56 PM)effone Wrote: @shade:
Can't it be done with this?
if($mybb->input['method'] == "quickreply")
{
	// Do something ...
}

Also. But other plugins might use the quick reply system without actually setting the method to quickreply, so you might lose some functionalities. Checking for the ajax token will cover them as it's used also in the core.
[Image: fSGNVQj.png]
Reply
#7
Not Solved
Guys thanks very much I have just changed how the error shows and now it works great
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)