[Resolved] In many to many relationship [cred_post_parent get=’id’] is not working properly
This thread is resolved. Here is a description of the problem and solution.
Problem:
I have many to many relationships Events-->session<--Members where session is child of both Event and Member post type. Everything is working fine except this:
Solution:
If there are multiple parents for a Custom post type (many-to-many), in the cred form we need to add 'post_type' attribute in the shortcodes, for example:
This support ticket is created 6 years, 9 months ago. 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.
Everything is working fine except
[cred_post_parent get='id']
[cred_post_parent get='title']
[cred_post_parent get='url']
When I click Add Session link from Event frontend the above shortcode works fine but from Member frontend the shortcode display title of the current page (where session form shortcode is placed).
I tried to debug and found that [cred_post_parent] is working where URL param is "parent_event_id" but is not working when URL param is "parent_member_id".
Thank you for contacting Toolset support. Ok as I can see Add Session link (child form) is not working for Members post type.
To debug this issue I need to take a look at your setup and to request temporary website WP-admin and FTP info for your site to debug further and to help in resolving this. Your next answer will be private which means only you and I have access to it.
=== Please backup your database and website ===
✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.
✙ Please add the Link to the [CRED forms] Edit Screen and [Page link] where you have inserted this view. OR any other things related to this issue.
I am able to reproduce this issue and I have now escalated this to our 2nd tier support for further review and we will get back to you with an update.
Optional: you may also get the parent values using custom shortcode if your issue is too urgent, because the ID does get passed correct in the url as I noticed. This is ofcourse optional alternative method until our 2nd tier reviews this.
Thank you for your co-operation and patience as we strive hard to resolve this.
1. I have created a custom function that you can use, please add this code in theme’s functions.php file:
function check_parent_type(){
// 'parent_event_id' will be your URL parameter of cred child form
if( isset($_GET) && $_GET['parent_event_id'] != '' ){
return 'parent1';
}
// 'parent_member_id' will be your URL parameter of cred child form
elseif( isset($_GET) && $_GET['parent_member_id'] != '' ){
return 'parent2';
}
}
==> Whereas “parent_event_id” & “parent_member_id” can be replaced by the URL parameter that you see in your cred child form url for each post type.
2. Please make sure to Register the custom function first in Toolset >> Settings >> Front-end Content >> Functions inside conditional evaluations (see attached screenshot).
3. In the CRED form please use these shortcodes with conditional output:
Just to be more clear, if there are multiple parent for a Custom post types (many-to-many), in the cred form we need to add 'post_type' attribute, for example:
I figured out the same that we have to mention post type short code as well. But the documentation of short code does not cite post type inclusion. If your mentioned syntax is the default syntax then please update the book review example here to include the post type. https://toolset.com/documentation/user-guides/cred-forms-for-child-content/