![]() |
How to return error phrase in attachdata_presave hook?
I'm trying to block certain attachments from being posted. When I make use of returning "false" in the attachdata_presave hook I can successfully stop the file from being saved in VB. However, when I try to customize the error message shown in the browser to the end-user, it only works when I am logged in as "admin". Registered users still see the standard error message.
Here's what I have in attachdata_presave Code:
$bannedmatches = $this->dbobject->query_first(" Quote:
Quote:
Thanks for your help, James |
Why would you go to all that trouble?, just don't allow the file type in the attachments manager?
That said you can display an error message like this example, if you create a custom hook (custom_template_permissions) HTML Code:
if (is_member_of($vbulletin->userinfo, 1)) These should help too :) HOOKS CALLED init_startup fetch_userinfo_query fetch_musername fetch_userinfo cache_permissions fetch_foruminfo style_fetch cache_templates global_start parse_templates notices_check_start notifications_list global_setup_complete newattachment_start attachdata_start upload_accept error_fetch newattachment_attach editor_wysiwyg_compatible newattachment_complete TEMPLATES CALLED newattachment newattachment_errormessage newattachment_keybit PHRASE GROUPS CALLED global posting prefix |
Simon,
Thanks for your help. I'm not trying to block certain types of attachments. I'm trying to block specific attachments by comparing the filehash of the file that the member uploaded to a list filehash values I'll maintain of "banned" files/attachments. I'm still trying to figure out why my error phrase is working correctly for the admin usergroup, but registered users are seeing the VB default phrase. I double-checked and both phrases are the same type. (Stock VB phrase) Front-End Error Messages upload_file_failed "Upload of file failed." (My custom phrase) Front-End Error Messages jb_file_not_allowed_here "This file is not allowed to be uploaded on our website." It's a mystery to me why different usergroups are seeing different phrases. Thanks, James |
Do you have your error phrase in the error phrases or in global or.....etc?
|
I put my custom phrase in "Front-End Error Messages".
Thanks, James |
Quote:
|
Yes. I know the code in the hook is being executed because the line above the line that sets the error is being executed:
Code:
$return_value = false; |
So if you disable your plugin and upload the file as a registered user, it works?
|
Quote:
--------------- Added [DATE]1328496982[/DATE] at [TIME]1328496982[/TIME] --------------- Maybe something weird is happening with the vB_Upload_Attachment datamanager? Here is where newattachment.php is getting the error text from: Code:
if ($error = $upload->fetch_error()) |
Quote:
|
All times are GMT. The time now is 01:06 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|