Skip Navigation

[Resuelto] No row is created in toolset_associations when using toolset_connect_posts

This support ticket is created hace 3 años, 6 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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: Africa/Casablanca (GMT+01:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por Simon hace 3 años, 6 meses.

Asistido por: Jamal.

Autor
Mensajes
#2064109

Tell us what you are trying to do? Connect two different CPTs using a custom script with toolset_connect_posts.

Is there any documentation that you are following? https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

What is the link to your site? Internal development

Issue:
* Two different custom post types made with Toolset Types CPT_X (parent) and CPT_Y (child).
* Relationship one-to-many (CPT_X -> CPT_Y) created with Toolset Types after the creation of CPTs and the data in these CPTs.

1. Running an import script with WP All Import and with the Toolset Types add on. No errors.
2. When WordPress action save_post_cpt_y() is called a function is executed where the current post_id of CPT_X and CPT_Y is called with toolset_connect_posts('relationship_slug', CPT_X_post_id, CPT_Y_postid)
2.1 Two rows are now created in the database table toolset_connected_elements with CPT_X_post_id and CPTY_Y_post id.
2.2 But no row is created in the table toolset_associations when using toolset_connect_posts() in the script and no relation is shown in WP admin GUI under the posts.
3. If I make the connection/relation manually in WP admin GUI a row in toolset_associations is created together with two rows in toolset_connected_elements and I can view the connection under each post in WP admin GUI.

Do I need to call another function in the script after toolset_connect_posts or clear a cache?

#2064353

Hello and thank you for contacting the Toolset support.

I run a test in a clean install with the latest releases, and I wasn't able to reproduce the issue. The function has added a line to the "wp_toolset_associations" table. And I can see the link at the parent's post edit page in WP Admin. Check this screenshot, I hope it is clear to describe what I meant enlace oculto

To better help you with this issue, I'll need to take a closer look at the code that you are using and how it is been executed. Please provide as many details as possible. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

If you would like to give it a try in one of our test sites, you can log into it with the following URL enlace oculto
In that case, please let me know where the code is located and how do you make it execute?

#2069759

My issue is resolved now. Thank you!