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. Hello,
    [Sorry for my english, I’m French]
    I’d like add one custom field with a default value but not display it in the upload page.
    I could use Css to hide these field, but I’d prefer do it without indication of these field in the code page.
    Is it possible with the hook system to add code in order to add one “userdata_field” before call the function “wfu_log_action” and like that have one record in the wfu_userdata table with the custom field I’d like to record ?
    I hope I’m clear.
    Thanks

  2. FloridaCracker

    Hello, I am trying to add a hook to wfu_after_file_upload and I have 2 questions:

    1) I need go into WP database and add some info to a table in WP database, so I need to execute an action on server side. Is it possible to create a hook similar to “wfu_after_file_upload” but on server side in functions.php?

    2) Is there shortcode or a variable I can access from server side in PHP to fetch the name of the file the user just uploaded? I looked in the WP database but could not find any uploaded files in wp_posts or any other tables that would give me that information.

    I am a mediocre programmer who greatly appreciate any suggestions. Thanks!

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