[Gelöst] Setting up post relationship with form not made with cred
Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.
Problem:
How to make relationship with parent post using CRED form from child form.
Solution:
When using Types posts relationships, the parent of a given type is stored in a postmeta table with key name equal to: _wpcf_belongs_{parent-post-slug}_id
Where:
Replace {parent-post-slug} with your parent post type slug value.
This support ticket is created vor 7 Jahre, 4 Monate. 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.
I use all from Toolset, but for a specific form i used Formidable Pro. Now i have a problem how i can make the connection with the Parent Post type. So that the parent of this post is Auto selectet.
---------
Parent Posttype
- Event (slug:event)
Child Posttype of Event
- Reviews (slug:reviews)
--------
What i have tryed is to put the Formidable Pro Form in an CRED Post Forms.
add_action('cred_save_data', 'review_action',10,2);
function review_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==25)
{
//get the Post ID of the current event:
$event_id = $form_data['container_id'];
//update the new review post parent field with this ID:
update_post_meta($post_id, '_wpcf_belongs_event_id', $event_id);
}
}
Hello. Thank you for contacting the Toolset support.
When using Types posts relationships, the parent of a given type is stored in a field:
_wpcf_belongs_{parent-post-slug}_id
Let’s assume that we are displaying a Car post type that has a Maker as a parent post type.
Each Car will store its Maker (parent) id in the field _wpcf_belongs_maker_id.
So what you need to do is - Using whatever form you create entry you need to make sure that following code should be run in order to make relationship between your chiild and parent post:
1)
Could you please share problem URL where you have added your CRED form? Also, please explain me how you are getting your parent ID?
2)
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.