Support Forum
Support › MB Relationships › auto create the values for relationships
We are building a cpt system with three "types" ie
Users
Items
entries.
The brief is for a talent competition. There is a master list of Items to be performed at the competition.
The parent of the entrants will create a WordPress user and log in. Once they are logged in they must then create "entries" The entries will be a select field with a short code to bring the list of items in. Then in a repeater field parent will add the participant details ( there may be up to 10 Participants per entry per item).
Now, this is where we need the first relationship ie the user, and the "entries" he has created. ( a user may create many entries) the reason for this is we want to list all the entries on his profile page. Now we don't want the user to manually create the relationships between his profile and the entries he created. We need this to be done based on the values of the selected form.
The same will be in effect with the item and entry. As this is a 100% user-based data creation dataset we need to automate this as much as possible.
It is our intention to use piotnet forms for the front end as they offer very powerful integrations and processing abilities however they are not able to assist with the automatic updates of the relationship fields
Hello Pat,
There is no option to update the relationship field automatically, you need to manually select it. Or if you are familiar with coding, you can follow this documentation to know how to create relations programmatically https://docs.metabox.io/extensions/mb-relationships/#creating-connections-programmatically
Hi Peter,
thank you for your reply. Unfortunately, this didn't address our problem. I may have used the wrong terminology or missed the link you sent me.
My question was not about creating a new relationship between two objects. my question was about connecting two entries(posts) in the cpt. When you add a new post in the cpt you need to connect the entry in the meta box.
I need to know if there is a way to fill in the value of the "item" id in the meta box when the "entry" CPT is completed. There is a select field in the "Entry" cpt that collects the value of the "Item" cpt and I need this than to auto-fill the relationship meta box for this relationship.
I hope this explain the issue a bit better
When a user creates entries, he will be the author of the entries and no need to set up a relationship. But if you want to allow them to select entries manually, you can use the feature MB Relationship and then use a WP Query to display selected entries only. You can do the same with two post types: item and entry.
Hope that makes sense.
Hi Peter,
Thank you for you information. The user entries make sense. How about the relationship between the "items and entry fields" then I still need to connect them on the meta fields manually. I still need to connect every entry to an item.
It's not possible to create a relationship between an object and a custom field of another object. The plugin MB Relationships helps you to create relationships between objects only (post, term, user). Please read more on the documentation https://docs.metabox.io/extensions/mb-relationships/