Skip Navigation

[Gelöst] How to restrict the list of options appearing with the relationship in Cred

This support ticket is created vor 4 Jahren, 11 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Pat vor 4 Jahren, 10 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#1401689

Pat

Hello,

I have a relationship (one to many) between 2 postypes. I have a Cred form where I have placed a field that is related to this relationship.

In the standard way of working, all potential posts that have been created are listed when you fill the form in the frontend.
What I would like is to restrict the amount of posts to be listed (ie : use a custom field belonging to this post as a sorting parameter)

Is there a way to manage this?
£Regards
Pat

#1402319

Hello, there's not really a built-in way to do this. There are a couple of ways you could implement this with custom code:
- Use a generic select field instead of the post relationship field. Set the options for the generic select field using a View, filtered and limited however you want. Use the cred_save_data and toolset_connect_posts APIs to set the parent post based on the User's selection
- Use the pre_get_posts hook to modify the query used by WordPress to fetch the parent post options.

Let me know if you have additional questions about one of those approaches.

#1402435

Pat

Hi Christian,

I understand your proposals, but to me, I was wondering Toolset can propose a "built-in" solution !
As said, when you use the relationship inside a Cred form, it would be good to have a way to sort the potential results (you don't need to give access to all results each time !). As a beginning, just change the ordering for example?

I'm sure this could be a good proposal for the future anyway !

Regards
Pat

#1403269
Screen Shot 2019-12-09 at 12.13.51 PM.png

I agree, a built-in customization tool would be very useful. I encourage you to submit your idea here: https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

Until then, you can use some of the options in the Form builder to adjust sorting. See the attachment here.

#1418349

Pat

Hi Christian,

I have submitted the idea to the team.
Thanks
Pat