Log in

View Full Version : Quick Reply Error Message


Boofo
03-22-2008, 11:32 AM
If I want to show an error message after a quick reply is submitted, what hook do I need to use for that?

Dismounted
03-22-2008, 12:26 PM
Add to the $errors array.

Boofo
03-22-2008, 12:28 PM
You lost me. Where do I do that?

Dismounted
03-22-2008, 12:44 PM
Look around the hook "newpost_process". ;)

Boofo
03-22-2008, 12:49 PM
Ok, I already have an error showing for this mod at newreply_post_complete. The quick-reply uses newpost then and nothing else uses that? This is the code I added to the newpost_process hook and it didn't do anything.

if ($vbulletin->userinfo['automod'])
{
$vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "goto=lastpost&t=$threadinfo[threadid]";
eval(print_standard_redirect('redirect_automod', true, true));
}


When I add it to the newpost_complete hook, it throws a vb error but doesn't say what the error is.

Dismounted
03-23-2008, 02:58 AM
You don't print standard errors. You just add an extra variable to the end of the $errors array.

Boofo
03-23-2008, 03:22 AM
The print standard errors works fine in the other hooks. Or is it just this hook it won't work in?

You lost me on the extra variable. The only thing I saw in the files before that hook was $errors = array();

Dismounted
03-23-2008, 04:12 AM
The print standard errors works fine in the other hooks. Or is it just this hook it won't work in?
If you haven't noticed, QR is usually AJAX.
You lost me on the extra variable. The only thing I saw in the files before that hook was $errors = array();
Add to the array:
$errors[] = 'Some random error occured.';

Boofo
03-23-2008, 04:17 AM
So, like this would work for that hook then?

if ($vbulletin->userinfo['automod'])
{
$errors[] = $vbprase['utomod'];
}

Dismounted
03-23-2008, 04:18 AM
Which hook? You have to make sure the hook isn't below the check for errors.

Boofo
03-23-2008, 04:35 AM
Here is what I am using in the newpost_process hook.

if ($vbulletin->GPC['fromquickreply'] AND $vbulletin->userinfo['automod'])
{
$errors[] = $vbphrase['utomod'];
}


And still no error shows when I hit submit.

Boofo
03-24-2008, 01:45 PM
Anyone have any ideas on this?

Lynne
03-24-2008, 02:12 PM
Have you tried using text instead of a phrase in your error message? At least then you can see if it works and if it just doesn't like phrases.

(I'm actually following this because I have custom script running in my attachment uploads and have never been able to get it to spit out errors so I'll probably try something similar to what you do to get this to work.)

Boofo
03-24-2008, 02:26 PM
Yeah, I tried it with words after trying the phrase and nothing. :(

Dismounted
03-25-2008, 05:09 AM
Are you using Firefox?

Boofo
03-25-2008, 05:13 AM
No, sir. IE7.

Is the code right for that hook?