MyBB Community Forums

Full Version: Yet another PHP help is needed Sorry!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Guys how how to show errors inside the newthread and editpost pages? I use error expression but it exits the the page what error expression mybb uses to show errors in the same page?

[Image: ScreenShot041-2.png]
Those are inline errors made by inline_error function. You can add additional errors by extending the errors array like this:
if($something) $errors[] = $lang->your_error;
Thanks very much D666 how should I combine that with this;
if ($chars < $minimum_characters)
error
I assume that's for the plugin you were talking about in another thread? Or was that a core edit?

It depends on where you've hooked, because the $errors variable may not be available to you. What hook are you using?
Yeah I am talking about this one: http://community.mybb.com/thread-149762.html
But I am wondering is I can do it by simply editing code files?

I am hooked to:
$plugins->add_hook("newthread_do_newthread_start", "threadlimit_run");
$plugins->add_hook("editpost_do_editpost_start", "threadlimit_run");
Those are the wrong places to hook to in this situation. I need to go to sleep so I can't elaborate further, but try checking out the datahandler_post_validate_post hook in inc/datahandlers/post.php. It looks like what you need.

You probably need to hook there, then use something like this code:

if $messageLength > $maxMessageLength
{
$this->set_error("too_long");
}

Then create a language file and set $l['too_long'] to "The message length is too long".
@Seabody thanks you very much. @SentoWeb had managed to fix all my issues.
Thanks very much +1