I have 2 CPTs setup. Exhibitor CPT has Brand CPT as a child.
I have a page which has a button where they can add a new brand and link it to the exhibitor using the cred_child_link_form shortcode [cred_child_link_form form="2872" parent_id="-1" text="Create new brand" target="_self"]
This was working but has stopped at some point over the last few months. I've noticed in the database, the ones that work have a entry in post_meta _wpcf_belongs_ob-exhibitor_id
What would I need to do to fix?
Hi, please tell me a bit more about your setup.
- Have you migrated to the new post relationships system? If not, you would see a message about migration in the Toolset > Relationships dashboard. If so, you would see a list of Relationships appear there.
- In the page where the create child link should appear, is the link in a View or Archive of Exhibitors, or is the link in the single Exhibitor page template?
Also you mentioned that it stopped working. Please let me know more specifically what is happening.
- Does the create child link appear on the page?
- Does the link lead to the wrong destination when clicked?
- What URL does the link lead to?
- Does the link lead to a Form that doesn't work?
- Does the Form create content but not connect it in the post relationship as expected?
Yes, I ran the migrate option which completed successfully but no change.
The create child link is shown in a view of exhibitors which has the option 'Post author is the same as the logged in user' selected.
The URL links to a page with another view which shows the brand CRED edit form. This form works and I can add a brand but it does not create the post relationship.
I can give you access to a staging site if that would help?
Yes I think that would be helpful. Please provide login credentials here in the private reply fields and let me know where I can find the View of Exhibitors on the front-end of the site. If this User is not an admin User, I will probably need an admin login as well so I can check out the setup in wp-admin.
Hi, I was able to log in to the Exhibitor Zone using the credentials you provided, but I don't see Exhibitor details or Brand details and I'm not quite sure where to start adding those. Should I create the Exhibitor post first in wp-admin?
I've added an exhibitor to the admin login so you can see the link on the front end here
Okay I think I have it working now. The problem is that in older versions of CRED, it was sufficient to use the parent post ID in a URL parameter to set the relationship automatically. Now, the URL isn't sufficient. You must also use a post relationship field in the Form Editor. Normally the Form Builder will generate this field automatically when you create a Form, but in this case your Form already existed. I'm attaching screenshots here showing how I added the relationship field. Then, since you don't want to display this field to your clients, I added some CSS to a wrapping div to hide it. Here is the final code:
<div style="display:none;">[cred_field field='@ob-exhibitor_brand.parent' class='form-control' output='bootstrap' select_text='--- not set ---' author='$current' urlparam='parent_ob-exhibitor_id']</div>
Check and let me know if the problem is not resolved.
Yes, working well thank you! I appreciate you sorting that and for the clear instructions 🙂