Crocoblock/suggestions

Enable "Insert Attachment" for Guest Users in JetFormBuilder

Opened this issue · 1 comments

Currently, in JetFormBuilder, the "Insert Attachment" option for media fields is only available for logged-in users. However, there are many use cases where guest users (non-logged-in users) need to upload files and have those files automatically inserted as attachments in the WordPress Media Library. This limitation makes it challenging to handle file uploads from guest users effectively, as files are uploaded but not attached properly.

Request that the "Insert Attachment" feature be extended to guest users. This will allow for seamless handling of media files uploaded via forms, regardless of the user's login status.

  • Allow the "Insert Attachment" option to be toggled for all user roles, including guest users, within the JetFormBuilder UI.
  • If the option is enabled for guest users, ensure that:
    -Files uploaded by guest users are inserted as attachments in the Media Library.
    -The metadata (media ID and URL) is stored properly based on the field's Value Format setting.

Hi @Dims8

Now our team is working on more priority tasks. But in the future we do not exclude the possibility of adding this functionality to the core of our plugin.

Thank you for your understanding.

But you can use this solution:

  1. Add the 'allow-insert-attachments' custom class to the Media field https://prnt.sc/QEedIUCLHqWq
    You may add a class with a format, like this:
    allow-insert-attachments-id - if the Media field format is Media ID https://prnt.sc/qZZyIfxaXYdh
    allow-insert-attachments-url - if the Media field format is Media URL https://prnt.sc/XhfA8bYgMiCC
    allow-insert-attachments-both - if the Media field format is Array with Media ID and URL https://prnt.sc/fUAeNHgA13DM
    If you set no format, it will be set to 'id'

  2. Then add the code below to the Code Snippets plugin or to the functions.php file of your current theme.
    https://gist.github.com/Crocoblock/d4900630b15f548b6be13e8a61960db6

The code works on 3.0.4 + versions only!

  1. Configure the Media field: https://prnt.sc/-9_oIOeudD67
    You can watch a video tutorial for guidance: https://youtu.be/ZKs7AT1Vpp4

Please be aware that restricting uploads for non-logged-in users is a security measure, so you should avoid allowing them when possible.