Skip Navigation

[Gelöst] Relationships migration of Connecting CPT’s with intermediary CPT via CRED Form

This support ticket is created vor 5 Jahre, 9 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Author
Artikel
#919610
migration error.gif

Hi Minesh,

This is related to the issue you helped me with.
https://toolset.com/forums/topic/connecting-two-cpts-with-intermediary-cpt-via-cred-new-form/

I am getting prompted by Toolset to update the Post Relationships. When I run the migration code is says it has detected legacy realtionship code that could cause compatibility issues. It's related to the code you created and flaced in the functions.php file in the child theme. (see screenshot).

I thought it best to run this by you before I fully run the update to make sure it does not break anything.

Please advise,

Respectfully,
Ronald

#919772

Hello,

In the new post type relationships of Types plugin, you will need to use new API function to connect posts, I suggest you try these:
1) Backup your website,
2) Run the Relationships migration,
then you will be able to get the new relationship's settings
3) follow our document to setup your custom PHP codes:
a) in the custom PHP codes:

// fetch existing writer posts and delete it
        $result = get_posts(array(
                            'fields' => 'ids',
                            'post_type' => 'writer',
                            'meta_query' => array(
                                array(
                                   'key' => '_wpcf_belongs_article_id',
                                   'value' => $post_id,
                                   )
                                    
                             )));

Replace it with function toolset_get_related_posts()
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

This part:

        update_post_meta($insert_post_id, '_wpcf_belongs_article_id',$post_id);
        update_post_meta($insert_post_id, '_wpcf_belongs_member_id',$_POST['_wpcf_belongs_member_id']);

replace with the function toolset_connect_posts()
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

#920100

Thanks Luo,

Scary stuff, relations migration, function updates. I'll need to do this over the weekend when no one is one on the site, hence why I'm keeping this support ticket open. I'll let you know how it goes.

#920138

OK, please update this thread if you need more assistance for it, and I have enabled the private message box, in case you need help to modify the custom PHP codes.

#924840

Hi Luo, I will be performing this update this weekend so just to give you a heads up... probably on Sunday night, Seattle time.

#948000

OK, please update this thread if you still need assistance for it, thanks

#948111

Yes, the new post type relationship does Backward compatible with old version of Types plugin, so your codes will work.

So you don't need to be concerned, and everything should be setup correctly.

But for future version of Toolset plugins, it is recommended to migrate your codes to the new post type API, see my answer:
https://toolset.com/forums/topic/relationships-migration-of-connecting-cpts-with-intermediary-cpt-via-cred-form/#post-919772

#948464

I'm glad my code works after the migration but it sounds like there could be problems with future plugins. I will tackle this another day. Thank you for your help Luo. Don't be surprised if you see my name again during future Toolset upgrades.

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