Skip Navigation

[Resolved] toolset_connect_posts not working

This support ticket is created 3 years, 4 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 3 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#2107383

i have a error while connecting 2 posts by hook...
toolset_connect_posts( 'product-participant', $product_id, $New_participant_id,true) ;

it used to work .

the error in log code isÇ
2021/07/06 11:34:59 [error] 11458#0: *243513 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught InvalidArgumentException: The intermediary post must be null, a post ID or a WP_Post instance. in /home/beoryih8/domains/beor.co.il/public_html/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/inc/public_api/m2m.php:550

#2107469

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As per the API doc for the function: toolset_connect_posts, the forth argument is for intermediary post.
=> https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

int|WP_Post|null $intermediary Optional. The intermediary post to use for a many-to-many post relationship. If it is not provided and it is needed, a new post will be created.

I'm not sure why you are using the true as the forth Argument.

toolset_connect_posts( 'product-participant', $product_id, $New_participant_id,true) ;

Can you please try to exclude the forth argument if its not required by you and check:

toolset_connect_posts( 'product-participant', $product_id, $New_participant_id) ;

In addition to that please make sure that the variables $product_id and $New_participant_id has been assigned the right values.