Skip Navigation

[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:

[cred_post_parent get='id']
[cred_post_parent get='title']
[cred_post_parent get='url']

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:

ID: [cred_post_parent get='id' post_type='event'] <br />
Title: [cred_post_parent get='title' post_type='event'] <br />
URL: [cred_post_parent get='url' post_type='event']

Whereas 'event' is the parent's custom post type slug.

Relevant Documentation:
https://toolset.com/documentation/user-guides/cred-forms-for-child-content/

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.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 9 replies, has 2 voices.

Last updated by Khurram 6 years, 8 months ago.

Assisted by: Noman.

Author
Posts
#550635

I am trying to:
I have many to many relationships Events-->session<--Members where session is child of both Event and Member post type.

I followed https://toolset.com/documentation/user-guides/cred-forms-for-child-content/ to create cred child for for session. I created content template for Event and Member post types and called 'cred_child_link_form' from both templates for session.

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".

#550698

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Khurram,

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.

Thank you

#550895

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks, I am working on it at moment and trying to reproduce same problem too. I will update you accordingly soon. Thank you

#551019

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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.

#551184

Hi Noman,

I will be waiting for a response from 2nd tier support for a permanent resolution.

In mean time please guide me towards short code as a temporary option 2 so I can proceed with development.

Regards,

#551449

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Register custom function.png

Hello Khurram,

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:

[wpv-conditional if="( check_parent_type() eq 'parent1' )"]
ID: [cred_post_parent get='id' post_type='event'] <br />
Title: [cred_post_parent get='title' post_type='event'] <br />
URL: [cred_post_parent get='url' post_type='event'] <br />
[/wpv-conditional]
 
[wpv-conditional if="( check_parent_type() eq 'parent2' )"]
ID: [cred_post_parent get='id' post_type='member'] <br />
Title: [cred_post_parent get='title' post_type='member'] <br />
URL: [cred_post_parent get='url' post_type='member'] <br />
[/wpv-conditional]

==> Whereas ‘event’ and ‘member’ are parent CPT slugs, can be replaced with post type slug.

I hope this workaround solution is good for your case. Thank you

#552016

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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:

ID: [cred_post_parent get='id' post_type='event'] <br />
Title: [cred_post_parent get='title' post_type='event'] <br />
URL: [cred_post_parent get='url' post_type='event']

Then the shortcode works fine, in this case 'event' is the parent's custom post type slug.

#552476

Hi Noman,

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/

Regards,

#552481

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Yes, its already reported for documentation update and doc will be updated soon.

Have a great day,
Thank you

#553012

Thanks for support Noman.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.