Hello, I am trying to set up a site with many-to-many relationships similar to the example here: https://toolset.com/documentation/user-guides/many-to-many-post-relationship/. In my case, I have a band user types who submits a band custom post type entry to the site and then associates their appearances to events. The band user type is the new element to the example and I'm using other plugins to restrict the band to one band custom post type entry.
I'm trying to find a way to have the band user log in and have a simple way to associate their band custom post type entry with an event. What I currently have working so far is the band user type registers and submits their band custom post type entry. I also have a members section where they're logged in as a band user type and the band user can see a list of events that are in the database.
I have two things I'd like to add. First, I need a mechanism for the logged in band user to associate their band custom post type entry with events. I'd like to make it as simple as clicking a button to associate the band custom post type entry with the event.
Second, I'd also like to make it so that when a band custom post type entry is associated with an event, the event is no longer listed to the logged in band member. I don't want bands to be added multiple times to a single event.
Please let me know if I can provide any more information on my issue.
Thanks,
Collin Condray
Director of Technology
BlueZooCreative.com
...I need a mechanism for the logged in band user to associate their band custom post type entry with events. I'd like to make it as simple as clicking a button to associate the band custom post type entry with the event.
Okay you can do this with a new post CRED Form that creates your intermediary post type (Appearances in our example). When you create the form, autogenerate the form contents. Then, modify the generated cred_form contents so that it only includes 4 things inside the cred_form shortcode: the form_messages field, the parent Band select field, the parent Event select field, and the submit button. Don't worry, your Users will only see the submit button, I'll explain below.
In the parent Band select field shortcode, you can predefine the parent band using the "value" attribute to insert the current User's Band ID. How you determine that Band ID is not clear to me based on your description, and could be as simple as reading a custom field from the current User's profile (wpv-user shortcode: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user). Or it could be as complex as setting up another View that queries Band posts based on the current User's ID somehow and returns the related Band post ID. I would need more information about how you associate Bands and their Users to be able to give more accurate information here.
In the parent Event select field, you can predefine the correct Event parent using the "value" attribute in the cred_field shortcode as well. If the CRED form is shown on an Event page or in a View of Event posts, that's as simple as value="[wpv-post-id]".
You don't want to show these parent select fields to your Users, so you can wrap them in a hidden div using CSS. Then you can style the Submit button to say something like "Play at this Event". Place that CRED form on the Event page or in a loop of Event posts, and you've got a button that will allow your Users to link their Band with a specific Event.
Second, I'd also like to make it so that when a band custom post type entry is associated with an event, the event is no longer listed to the logged in band member
Views offers conditional HTML, so you can test specific criteria to determine whether or not to show some content. How the conditional is set up depends on how you have Bands and Users associated with one another. More info about conditional HTML here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
Let me know if you need additional information about this.