Skip Navigation

[Resolved] How to use relationship fields?

This support ticket is created 3 years, 4 months ago. 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.

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)

Author
Posts
#1866917

Tell us what you are trying to do?
I am struggling to understand the concept of relationship fields. Where can I use them and how much freedom I have with them?

Is there any documentation that you are following?
I have read your document on post relationship that gives example of two CPTs: 1) Student and, 2) Class. You suggested using Grade as a relationship field that is common between the two. It makes sense but I am still struggling to understand the concept.

My product problem: I have two CPTs: 1) Project Prompts and, 2) Project Submissions. I want to enable people who submit "project submissions" to "rate" a "project prompt" so that other users know the quality of the "project prompt" before diving into it. Every "project prompt" can have multiple "ratings" from different users.
My question: Should I user relationship fields to capture "project prompt ratings" ? Or should I create a new post type "project prompt ratings" and show it right after a "project submission" and link it to the "parent project prompt" so that users can rate a "project prompt"?
I want to ask users a few questions as they rate a prompt so it will be like a mini NPS survey. Will relationship field option restrict me vs a "prompt rating" CPT?

Is there a third way that I am not aware of?

#1867049

Hello, relationship fields are only available in a many-to-many (M2M) relationship scenario. It sounds like you want to allow multiple Users to rate a single Project Prompt post, and each "Rating" can only apply to one Project Prompt post. You did not mention any direct relationship between Ratings and Project Submissions. If my description is accurate, I don't think relationship fields are applicable here. I think you need a separate custom post type for Ratings, or a repeatable field group (RFG) inside the Prompt post type. Either could achieve what you need to capture - repeated groups of inputs, related to a single parent post. The child post type approach requires you to create a One-to-Many relationship between Ratings and Project Prompts. The RFG approach requires no extra custom post type or relationship setup.

The other main differences between the RFG approach and the child post type approach:
- Individual rows of RFGs do not get their own custom URLs on the front-end of the site, nor do they get their own editor page in wp-admin. RFGs must be edited in the parent post editor screen, and if you want to display them on the front-end of the site you would need a View.
- Child posts in a custom post type get their own custom URLs on the front-end of the site, and they get their own editor pages in wp-admin. You can also display them in Views.

On the front-end of the site, RFGs and child post types are managed similarly. Only a single instance can be created/edited in a single Form. In other words, only one "row" of an RFG, or one child post, can be created or edited in a single Form. Nested RFGs are not supported in Forms. In either case, you can allow your Users to submit a Form that generates one row of an RFG, or one child post, for a known parent Project Prompt post. Those features are possible without any need for extensive custom programming.

#1867205

This sounds great, Christian. Thanks for the detailed answer.

The "project submission" post type will have a 1-1 relationship with a "rating" because I only want people who have submitted a project "via project submission" to rate a "project prompt" ONLY once.

Seems like child post is the way to go. Thank you.

#1867207

My issue is resolved now. Thank you!

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