[Forminator] Store uploaded files in separated folders

When a visitor upload files it is uploaded to the month folder. If I have 20 clients per month and each one will upload 5 files that means 100 files. This is messy.

I’d like to have an option for each visitor to upload his files to a subfolder so,

client 1 = folder 1

client 2 = folder 2

Can this be implemented in the future? And is there any easy custom code I can use to achieve this?

  • Dimitris
    • Support Star

    Hello there Mohamed,

    hope you’re doing well and appreciate the request here.

    If your clients using this form aren’t logged-in WP users, then I’m afraid that this would complicate things more, as we can’t be sure about the client’s identification, unless we also take into account another form field like the First & Last Names. Could you please let me know if these clients are logged-in WP users in your website or not? If not, could a check based on Name could work for you? Please advise!

    Warm regards,

    Dimitris

  • Dimitris
    • Support Star

    Hello Mohamed

    I’m afraid that it’d be too difficult to safely locate users if these aren’t logged-in, so I’m moving this thread from Features&Feedback to our Support forums and I’ll ping our Second Level Support team, just in case they can provide a workaround for this specific use-case (validate users via a Name field).

    We’ll keep you posted here as soon as possible, your patience on this is highly appreciated.

    Thank you,

    Dimitris

  • Tho Bui
    • Staff

    Hi Mohamed,

    I hope you’re well today!

    I have prepared a custom snippet which you can use as a guide here :

    https://gist.github.com/wpmudev-sls/a22b51fa5448c2d8f1eea4f49dd5e981

    You can download a zip, unzip it, open the file and change name-1 with your name field id or another field to identification. Maybe the name field is not unique, so if you want to unique folder I suggest use mail field instead of.

    Then upload file forminator-store-uploads-files-in-separated-folder.php to your wp-content/mu-plugins folder. If that folder doesn’t exist you can simply create it.

    If you want to retrieve the file you also can use the get_file_path method, ex:

    WPMUDEV_Forminator_Custom_Upload_Path::get_instance()->get_file_path( $file_name, $user_name );

    If you are not familiar with mu-plugins you can read about them here:

    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    or you can paste it in your child theme’s functions.php file.

    Kind regards,

    Tho Bui

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.