• Resolved Jakob Smith

    (@diakrisis)


    Is it possible to have attached files deleted after the form has been submitted?

    They are placed in the media library, which I would like to avoid.

    If I use the {upload-1} tag in a mail notification, it shows the filename as a link to the file in the media folder. Can the tag be filtered, so only the filename is shown, without the link?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @diakrisis,

    Thank you for contacting us.

    The setup for upload field is to allow users to submit their files attachments which are stored in Forminator uploads folder. However, there is an option you can enable or disable to not store these files in the media library, so the users will not get the link to media folder. Check in your upload field settings and look for the option “Show files in media library” and set it to disable.

    Let us know if you have any additional questions.

    Best,
    Jonathan S

    Thread Starter Jakob Smith

    (@diakrisis)

    @wpmudev-support9
    That thing indeed works, but the files are still stored in a folder on the server and I would like to avoid that.

    Even if I have chosen “Disable store submissions in my database” for the specific form, the attached files are uploaded to the server and a direct link is provided in the mail notification, if I use the tags like {upload-1}.

    I would like the attached files to be listed in the mail notification, but without links to the files on the server AND the files should not be uploaded to the server.

    I’m trying to write some code myself to delete the uploaded files after the form has been submitted, but I’m having a hard time finding the right hook. I know you have API docs, but they don’t list the available hooks.

    I have been looking on earlier tickets as well of the code of Forminator and I’ve been trying this hook without luck:

    forminator_custom_form_after_handle_submit

    Does it work? I’m getting some errors related to Akismet code in Forminator when using it.

    Or can I do something with this:

    wp_ajax_forminator_submit_form_<and something more here>

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @diakrisis

    I hope you are doing well.

    I pinged our developers to verify which is the best approach for this, we will reply once hearing back from the team.

    Best Regards
    Patrick Freitas

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @diakrisis

    I hope you are doing well.

    Can you please try two scripts?

    To remove the uploaded file:
    https://gist.github.com/patrickfreitasdev/97580e45e35b8f24030a41c713b190ee

    For email, you can use a custom macro, for example:

    {filename-upload-1}

    It adds only the name of the file:

    https://gist.github.com/patrickfreitasdev/05919e3e4705960c8d6ab0b24f4d2c82

    You can add those as mu-plugin:
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Let us know if you have any additional question.
    Best Regards
    Patrick Freitas

    Thread Starter Jakob Smith

    (@diakrisis)

    @wpmudevsupport12

    Thank you VERY much for the provided code, which works perfectly.

    It’s an exact and precise answer to both of my questions. It will hopefully be of help to others too here.

    I have to write a 5-star review later.

    • This reply was modified 3 years, 6 months ago by Jakob Smith.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Delete attached files from media folder after form has been submitted’ is closed to new replies.