Skip Navigation

[Resolved] Add a Gallery (repeating image field) in Post Field Group

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Author
Posts
#2474499

Tell us what you are trying to do?
Scenario: We have custom post type that represents building sites. The building site's author is able to create the post with front end form. The building site post type has a Field group called Updates. Updates are managed with RFG. These updates consist of given description and photos or videos and a Date field. For Date and description fields there is no problem, but for Images and videos we need author to be able to upload multiple images or video within the front-end form associated to RFG. Subsequently we need to show these images and video in a gallery within a view of RFG.

<b>The problem is that Repeating Image is Disabled in RFG. Do you know a workaround or different approach to this?</b>

#2474711

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

The thing is that it already shows the information that:

Repeating Fields are currently not supported inside Repeatable Field Groups - a field can only have one value inside a Repeatable Field Group.

Having said that a different possible structure would be to create another post type lets say "Site Updates" and add the fields you want by created custom field group and assign this field group to display with "Site Updates" post type and then you should create one-to-many post relationship between post type that represents building site and "Site Updates".

Will the above mention structure help?

#2474793

Dear minesh,

Thank you for your valuable support!

Let's say we have 2 ways at the moment to solve this issue:

Easy Way:
We leave the RFG as it is at the moment and instead of multiple lines, Images and videos field we replace them with a WYSIWIG. This way the author could submit photos, videos, descriptions and more using the built in wordpress media gallery. This is not really a linear process but it certainly allows us to reach the goal shortly.
Question about this easy way:

  • Could the "building site" author only see his media into the wordpress gallery of the wysiwig of the RFG? (this is for security reason, because all building sites posts are password protected and information inside these posts are really confidential )

Hard Way:
Your approach of creating a second post type "site updates" could be very interesting, but we need to investigate it as we have to restrict access for security reason. This approach will let the author of the post type "building site" having a front end form where he can submit updates. These "site updates" are linked to the "building site" with a one-to-many relationship. That's could be very good but we need some confirmation before proceed developing this way.
Question about this hard way:

  • The logged-in user should select the main post "building site" which the "site updates" he is submitting is linked. Should the logged-in author only see his "building sites" in this front end form field? (we don't want users submit updates on other "building sites" that are not property of their company)
  • The post type "Site Updates" should not be accessible directly, as it will contain confidential informations. Is it possible to limit direct access to these posts but leave theme visible into the related post "Building site"?
  • The "Bulding site" represent a real renovation of an house or garden or building. It could have hundreds of updates. It means that a single company could have thousands of post type "site updates". Could it be a problem in website performance?

Said that i would like to let you know that we have a big company behind this project and they are willing to pay the Repeating Fields inside Repeatable Field Groups feature development.
I saw this feature request is 3years old and many Toolset developers are requesting it. is there any update on this?

#2474861

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Easy Way:
We leave the RFG as it is at the moment and instead of multiple lines, Images and videos field we replace them with a WYSIWIG. This way the author could submit photos, videos, descriptions and more using the built in wordpress media gallery. This is not really a linear process but it certainly allows us to reach the goal shortly.
Question about this easy way:

Could the "building site" author only see his media into the wordpress gallery of the wysiwig of the RFG? (this is for security reason, because all building sites posts are password protected and information inside these posts are really confidential )
==>
Toolset forms offers the way you can manage media permissions. Here is the Doc:
- https://toolset.com/course-lesson/using-the-native-wordpress-media-manager-in-front-end-forms/

You will see that option at:
=> Toolset => Access Control => Toolset Forms tab => Use any Media Library file when adding files to front-end Post Forms

Can you please check first and see this works as expected for you.

#2474871

Dear Minesh,
Thank you for working out of your working time, workaholic! 😀

Solution you shared seems not to work correclty with the Add media button in wysiwig field.
even if => Toolset => Access Control => Toolset Forms tab => Use any Media Library file when adding files to front-end Post Forms is not checked my custom user role user can still see others files in media library of wysiwig field.

I tried it with image(repeatable), video(repeatable), featured image, and file fields. It works good on this cases!

By the way when the media library is opened from add media button from wysiwig field it shows all media.
I think it is related to the custom permission set into the access plugin.
Check the screenshot i attached. In the form option it says that upload_files capability is required and i activated it. If i don't activate this capability then the Media Button doesn't show on wysiwig, even if i check "Use the WordPress Media Library manager for image, video, audio, or file fields(that i already said it doesn't affect wysiwig behavior)"

I would like that the option you mentioned in access plugin works for wysiwig also. Is it a bug?

in the meanwhile i'm using custom filters like this.

add_filter( 'ajax_query_attachments_args', 'role_azienda' );
function role_azienda( $query ) {
    $user_id = get_current_user_id();
    if ( $user_id && current_user_can('azienda') ) {
        $query['author'] = $user_id;
    }
    return $query;
}
#2475473

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Have you set your post type managed by access?

#2475607
Schermata 2022-10-13 alle 18.52.00.png
Schermata 2022-10-13 alle 18.51.33.png
Schermata 2022-10-13 alle 18.50.47.png
Schermata 2022-10-13 alle 17.48.27.png

Yes, i set access to manage custom post types, check the attachments

#2476047

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ahh, ok

I would like to know using what role you are allowing users to upload the image. I mean what capabilities you assigned to role "azienda"? If you created that role using Guest user then you will have to use the code you shared.

As you can see with the table given with the following Doc:
- https://toolset.com/course-lesson/using-the-native-wordpress-media-manager-in-front-end-forms/

There its mentioned that what user role will have what capabilities during access of media library. If the custom user role does not have those capabilities you will have to add such custom code which you already added.

#2476445

Dear minesh, you pointing on a wrong topic. The role "azienda" has been created with author or contributor user, i don't remeber exactly. But let me explain better.
Using access control to restrict media library to only show own files is working well!
On every forms and upon fields managed using wordpress media library i can see only the media uploaded by the current logged-in user Azienda.

The issue is only on the RFGs form that is actually using Wysiwig field with add media button enabled. When a logged-in user Azienda click on Add Media from that wysiwig button, then all media of all users are showed in the library.
Is there a solution for that? i think it could be a bug of the wysiwig on RFGs form.

To be sure of the bug i did a test.
i added two fields in a RFGs form: WYSIWIG FIELD and IMAGE FIELD.
If i click add image from the IMAGE FIELD then the media gallery show only current logged in user media files.
If i click add media from the WYSIWIG FIELD then the media gallery show all the media files of all users.

#2477541

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Indeed, there seems to be issue when you try to access media using form created for RFG and the WYSIWYG field added to RFG.

I see if WYSIWYG field is added directly to any custom post type it works as expected but it seems there is issue when field is WYSIWYG field and added to RFG.

However, I'm glad that you have workaround to go with as of now so I suggest you should keep using the workaround as of now as I'll just report the issue to our next level support and there will be no ETA on it when the fix made available.

#2478211

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I would like to inform you that this is a known issue to us and here is the errata page:
- https://toolset.com/errata/access-setting-to-limit-media-library-to-own-media-doesnt-work-with-add-media-button-of-wysiwyg-editor/

As I requested, you should keep using workaround you shared for now that will help you to take next steps with your project.

#2478651

Dear minesh,
Thank you for support. Next time I will search into “errata” section before asking solution here. I didn’t know about it before you linked to the known issue post.
Btw I want share this for future users:
2 temporary workaround.

1_Using this plugin seems to fix the issue: https://wordpress.org/plugins/frontier-restrict-media/

2_this custom code work only for grid view. Switching to list view will show all media files in media library, so I definitely do not recommend this solution.


add_filter( 'ajax_query_attachments_args', 'role_azienda' );
function role_azienda( $query ) {
    $user_id = get_current_user_id();
    if ( $user_id && current_user_can('azienda') ) {
        $query['author'] = $user_id;
    }
    return $query;
}
#2479037

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

thanks for sharing that information. This indeed will help other users.

You are welcome to close this ticket for now.

#2479401

Minesh is very helpful. Very good support. However the bug has not been resolved and need further investigation from developers team. stay tuned here - https://toolset.com/errata/access-setting-to-limit-media-library-to-own-media-doesnt-work-with-add-media-button-of-wysiwyg-editor/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.