Create Custom Filters and Actions for Iptanus File Upload

Iptanus File Upload plugin hooks logo

The Iptanus File Upload plugin supports a set of filters and actions for tailoring it to what you need; the full list is in a separate article.

Since version 3.6.0 you can write the code for them inside the plugin itself, from its Dashboard area, with no third-party plugin involved.

Say you want some JavaScript to run as soon as a file has been uploaded. That means implementing the wfu_after_file_upload filter.

Creating a hook

Go to the plugin’s area in the Dashboard, open the Hooks tab, and create a new hook:

The Hooks tab in the plugin's Dashboard area, with the button to create a new hook

The screen that opens asks for a title, a description, the code, a status (active or not), and where the hook should run — in the Dashboard or on the front end. Fill in a title and description of your own.

Filling in the code

Above the code box sit code templates, which save you writing a filter from scratch. Choose “After File Upload Filter” and press “Add Code“. The box fills with the filter function and comments explaining how to use it:

The code box filled with the After File Upload Filter template and its comments

Edit it so that a success message pops up when a file has uploaded. The finished code looks like this:

The edited filter code, showing the success message being raised

Set the Status to Active and press Save.

If the code is sound, the new hook appears in the hook list. If it is not, a message at the top of the screen explains the error and the hook is left inactive:

The hook list showing the newly created hook as active

From that screen you can activate, deactivate or delete a hook, and run bulk actions across several at once.

Trying it out

With the filter in place, upload a file from a page. Once it has uploaded, the message appears:

The upload page showing the success message raised by the hook

For more information or questions about the Hooks feature, please contact us.

The Iptanus team

Did this solve your problem?

5 discussions

Most recent: August 2022

Questions answered by Iptanus and other users.

  1. FloridaCracker

    To clarify, I am rewording my first question to what should be the parameter xxxxx in “add_action(xxxxx, my-custom-function)” if I want to hook on the after file upload event in my in functions.php file, and how can I fetch the filename in my-custom-function?

    1. It should be “wfu_after_upload”. This is the filter you should use. You can find instructions how to use this filter here.

      Please note that it is not a good practice to add actions inside functions.php, unless it belongs to a child theme of your own. If you use a normal theme and you update it then everything you have inside functions.php will be lost.

      The plugin’s Pro version has a special page in Dashboard to add hooks, which remain even if you update it. You can also use other free plugins, like Code Snippets.

      Regards

      Nickolas

Ask a question

Answered by Iptanus, usually within a working day.

Ask a question

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top