Problem: I have custom post types Enquires and Team Members. I would like my Guest users to be able to use CRED to create a new Enquires post and select one or more Team Members to associate with the Enquire post. Team Members can be associated with more than one Enquire. What type of post relationship should be used here?
Solution: Many-to-many relationships are designed to allow one or more type A posts to be related to one or more type B posts. These relationships are fairly easy to manage in wp-admin, but they are not as straightforward to manage in CRED forms. Some custom code may be required to create a generic multiselect or checkboxes field that captures a User's selections and applies them on the backend. You can use the cred_save_data hook to accomplish this.
Relevant Documentation: https://toolset.com/documentation/user-guides/many-to-many-post-relationship/
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/
https://toolset.com/forums/topic/how-use-a-shortcode-instead-of-options-for-cred-forms
https://developer.wordpress.org/reference/functions/wp_insert_post/
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 |
---|---|---|---|---|---|---|
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)
This topic contains 6 replies, has 2 voices.
Last updated by 7 years ago.
Assisted by: Christian Cox.