Home Forums Front-end Issues Gallery field Front end role user


Gallery field Front end role user

  • Hello everyone,

    I use acf_form to display a front end form to add some custom post type.

    This custom post type has a gallery field.

    But unfortunately, when a user with a “Subscriber” role try to click on “Add images to gallery field”, it’s not working.
    I have this error in my JS : TypeError: is undefined

    How can i permit to my Subscriber to add pictures ?

    Thanks everyone for your time!

  • This is because subscribers do not have permission to upload files. You will need to either assign them to a role that can upload files or you’ll need to alter the subscriber permissions to allow them to upload. This or similar plugins will let you do that.

    But, a word of warning. Allowing subscribers the ability to upload files can be considered a security vulnerability. I would not do this on a site where anyone can join the site. You might want to think about an alternative. For example, you could create a repeater field with image sub fields. Then you can use the repeater in place of the gallery. If you want to keep the gallery you could build either an acf/pre_save_post or acf/save_post filter to copy the images from the repeater into the gallery.

  • Thanks for the answer and sorry for the delay of mine!

    Perfect 🙂

  • I thought using the repeater with image fields was the best solution for this – but what would happen to the images when a row is deleted?

    I guess they would remain in the Media Gallery and then increase the disk usage on the server over time as people upload and change their images?

    Would appreciate anyone’s advice on a good way to approach Gallery fields on a front end form for users that have a Subscriber level of access.

  • Let’s play with us. I already downloaded it spider solitaire

  • Even if you use a gallery field the images will stay in the media library when removed from the gallery. To avoid this in either case you would need to create a filter that removed files no longer present in the fields and you’d need to compare the old values of the field with the new values to figure out what media needs to be deleted. For a front end form this could be done in an acf/pre_save_post filter.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Gallery field Front end role user’ is closed to new replies.