display a message to user after upload_attachment_do_insert hook ?

I am tinkering around with plugin development in my spare time.  My current project is one that adds some additional rules to the attachment upload process.

So far everything has gone smoothly and the online documentation has been very easy to follow.  I've created the basics of the plugin which is working as desired.  I've hooked into upload_attachment_do_insert and my plugin logic is correctly processing those additional rules including generating a filehash for uploaded files.

What I am trying to determine is how to best display an informational message to the users.

Take the following basic scenario.  The attachment being uploaded has the same filehash as an existing attachment in the database.  I would like to display a message to the user and provide a hotlink to the existing post so the user can review.

When I review functions_upload.php after where it runs hooks for upload_attachment_do_insert if it is not a previous attachment the code directly tries to perform the insert.

I've manually added some code before the insert operation such that if my plugin detects a duplicate the attachment will not be inserted and instead an error value is returned using $ret['error'].

This is working to an extent and I can see error message display briefly.

I have a few questions however.

First, does anyone have any clever idea on how I could signal an error back without having to edit functions_upload.php directly?  It's not a good practice to need to edit such files but I can't see any other way to signal back an error message before the insert completes.  Perhaps this is too niche a situation and manual edits to that file can't be avoided.

Second, is there any other mechanism to display an error to the user that does not use the jgrowl error display?

Lastly, if not is there any configuration that can extend the display duration or leave it in place until the user dismisses it?

Thanks in advance for any input.

Forum Jump:

Users browsing this thread: 1 Guest(s)