Skip Navigation

[Resolved] Post relationship doesn’t save

This thread is resolved. Here is a description of the problem and solution.

Problem:
A Toolset Form to add a child post doesn’t save the parent post id if there is another form before it on the same page.

Solution:
This resulted from a bug which was fixed in Forms 2.1

This support ticket is created 6 years, 3 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 17 replies, has 2 voices.

Last updated by davidS-53 6 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#954381
954347-2018_07_24_20_12_11_.png

Following up on https://toolset.com/forums/topic/error-the-parent-must-be-a-post-id-or-a-wp_post-instance/

Hi Nigel,

Sorry, has taken me a little while to get back to you. Here's my update: I have gotten rid of the modals- that's not a problem. The forms now exist on the content template pages (see screenshot).

However, the post relationships still don't work properly.

Here is the problematic block of code:

add_action('cred_save_data','func_custom_post_title',15,2);
function func_custom_post_title($post_id,$form_data) {
    if ($form_data['id']==243) {
        toolset_connect_posts('boat-safety-check',$_POST['@boat-safety-check.parent'], $post_id);
    }
    if ($form_data['id']==302) {
        toolset_connect_posts('safety-check-log-item',$_POST['@safety-check-log-item.parent'], $post_id);
    }
}

With that code commented out: the post form submits & redirects, but the relationship isn't saved.
With that code active: the post form doesn't submit correctly, returning The parent must be a post ID or a WP_Post instance error.

I then swapped the site over to 2017 to test the form without any of my custom code: post form submits & redirects, but relationship still isn't saved.

I've then disabled all plugins apart from the toolset ones, and it still doesn't save the relationship. I'll leave it in that state so you can take a look and work out what the issue is?

See previous post for access credentials.

Cheers!

#954526

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hello again

(I keep getting confused as to whether I should be calling you David or Brad.)

I'm trying to connect to your site at hidden link but the htaccess authorisation doesn't seem to be valid anymore.

Let me set up a private reply and you can update the credentials.

#955573

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I took a copy of your site to work on locally because it was very slow trying to load some of the pages.

Where do I find the form now?

Where is that screenshot in your initial question from? If I view a boat post on the front end I don't see the form.

#956454

Hi Nigel, the form is now on the individual safety check page. For example: hidden link

#956490

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

OK, got it, I've tested and seen the issue.

I'll see if I can identify why and get back to you.

#956598

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I found that the problem seems to be the other CRED form you have in the same Content Template (the safety check edit form). If I remove that then the log item form works correctly.

I'm trying to see if I can reproduce on a vanilla test site, or whether it is particular to your site.

#956605

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Yep, I reproduced it.

I've escalated it so that my colleagues can dig deeper and hopefully identify the cause.

I'll keep you posted.

#956716

Great, at least we know the cause; keep me posted on the progress getting it sorted. Cheers

#957087

Forgot to ask; is that bit of code the other support guy provided me still relevant? Do I need it?

#958766

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You shouldn't need any additional code for the parent post assignment.

It's not working because of a bug, not because you are missing something.

#1084084

Hi Nigel, Any progress on getting this sorted? Cheers.

#1084472

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

It is fixed in an update to Toolset Forms 2.1, which is currently in QA testing. That will take a few days and so barring any hiccups will be released mid next week.

Sorry for the delay, it is August when things tend to slow down a little because of holidays.

#1084860

Thanks- shall keep an eye out for that version number.

#1085641

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

OK. Let me just update the status here.

#1098584

Hi Nigel, Any update on the 2.1 release? Cheers.