[Résolu] Restrict the relationship options to posts created by the current user
This support ticket is created Il y a 5 années. There's a good chance that you are reading advice that it now obsolete.
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
[cred_field field='@crew-member-crew-certificate.parent' select_text='--- not set ---' class='form-control' output='bootstrap' use_select2='never' author='$current']
I have already tried deactivating all plugins except for toolset and swapping back to 2019 theme, and the dropdown still shows all the crew members regardless of post author.
Oh right, ok, that works. The docs are pretty confusing- "If used with new post relationships (Types 3,0+), it breaks the "order", "ordering" and "author" attributes."
It only breaks the attributes noted if you use "never" as the option for use_select2- perhaps be worth updating the docs to be clearer.
Actually, while we're on the topic, is it also possible to restrict cred_field options by parent post ID? Let me explain:
Scenario: A Boat has many members (boat-crew-member relationship- one->many). Members have many certificates (crew-member-crew-certificate relationship- one->many). Take this data:
Boat 1 - Member 1
- Member 2
- Member 3
Boat 2 -Member 4
-Member 5
-Member 6
If I know the ID of boat 1, for example, could I restrict the
[cred_field field='@crew-member-crew-certificate.parent' select_text='--- not set ---' class='form-control' output='bootstrap' use_select2='never' author='$current']
dropdown to only Members that belong to boat 1- ie. User 1, 2 and 3? Does that make sense?
Thanks for writing back and I apologize for the delay.
This kind of filtering won't be possible directly using the "cred_field" shortcode, but you can use a generic field that uses a custom shortcode, to generate the list of Members, as needed.
Note: the custom shortcode should return the options and the values for the generic select field in this JSON object format:
To get personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors: https://toolset.com/contractors/
For each new question/concern, please open a new ticket.