Skip Navigation

[Resolved] CRED Post Form may not be saving Post Reference to Post Meta

This support ticket is created 6 years, 1 month 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
- 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/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by Mukesh 6 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#1154955

I am trying to:
Using the cred_save_date api hook I'm trying to access a post reference field using the get_post_meta function. However I am seeing that the post_reference meta is not even stored as part of the parent post I was editing. In some cases it is showing however.
Link to a page where the issue can be seen:

I expected to see: Here you can see I"m printing out the post fields using the get_custom_post($post_id) call on the cred_save_data hook. Here it is showing the wpcf_attorney post meta which is a post reference field. t
[28-Nov-2018 21:41:05 UTC] Array
(
[_wp_page_template] => Array
(
[0] => default
)

[wpcf-follow-up] => Array
(
[0] =>
)

[_wp_old_slug] => Array
(
[0] => cred-auto-draft-ea3b6e897ca15c0696dede64cf069ca5
)

[wpcf-statement-confirmation-received] => Array
(
[0] => 0
)

[wpcf-pfp-billed-amount] => Array
(
[0] =>
)

[wpcf-reduction-letter-amount] => Array
(
[0] =>
)

[wpcf-final-payment-amount] => Array
(
[0] =>
)

[wpcf-write-off-amount] => Array
(
[0] =>
)

[wpcf-profitability] => Array
(
[0] =>
)

[wpcf-case-status] => Array
(
[0] =>
)

[wpcf-sales-rep-assigned] => Array
(
[0] => 12
)

[_edit_lock] => Array
(
[0] => 1543418787:1
)

[_edit_last] => Array
(
[0] => 2
)

[wpcf-patient-last-name] => Array
(
[0] => fffff
)

[wpcf-patient-first-name] => Array
(
[0] => ssss
)

[wpcf-attorney] => Array
(
[0] => 152
)

[wpcf-chiropratic-clinic] => Array
(
[0] => 274
)

[wpcf-medical-clinic] => Array
(
[0] => 274
)

[wpcf-clinic-city] => Array
(
[0] => Irving
)

[wpcf-doctor] => Array
(
[0] => 157
)

[_wpcf-ops-notes-sort-order] => Array
(
[0] => a:1:{i:0;i:3490;}
)

[site-sidebar-layout] => Array
(
[0] => default
)

[site-content-layout] => Array
(
[0] => default
)

[wpcf-ops-notes] => Array
(
[0] =>
)

[wpcf-lop-entry-date] => Array
(
[0] => 1543276800
)

[wpcf-patient-dob] => Array
(
[0] => 593740800
)

[wpcf-date-of-injury] => Array
(
[0] => 1542844800
)

[wpcf-date-shipped] => Array
(
[0] => 1543276800
)

[wpcf-lop-requested] => Array
(
[0] => 1543276800
)

)

Instead, I got:
In this post print as you see the wpcf-attorney is not present even though that is set on teh Post in the front-end
[28-Nov-2018 21:49:19 UTC] Array
(
[_wp_page_template] => Array
(
[0] => default
)

[_wp_old_date] => Array
(
[0] => 2018-11-27
)

[wpcf-follow-up] => Array
(
[0] =>
)

[wpcf-patient-last-name] => Array
(
[0] => llll
)

[wpcf-patient-first-name] => Array
(
[0] => rrrrrr
)

[wpcf-clinic-city] => Array
(
[0] => Arlington
)

[_wp_old_slug] => Array
(
[0] => cred-auto-draft-ea3b6e897ca15c0696dede64cf069ca5
)

[wpcf-statement-confirmation-received] => Array
(
[0] => 0
)

[wpcf-pfp-billed-amount] => Array
(
[0] =>
)

[wpcf-reduction-letter-amount] => Array
(
[0] =>
)

[wpcf-final-payment-amount] => Array
(
[0] =>
)

[wpcf-write-off-amount] => Array
(
[0] =>
)

[wpcf-profitability] => Array
(
[0] =>
)

[wpcf-case-status] => Array
(
[0] =>
)

[wpcf-sales-rep-assigned] => Array
(
[0] => 12
)

[_edit_lock] => Array
(
[0] => 1543418816:1
)

[wpcf-ops-notes] => Array
(
[0] => 2018-11-28: (start your comments here)
)

[wpcf-lop-entry-date] => Array
(
[0] => 1543276800
)

[wpcf-patient-dob] => Array
(
[0] => 110073600
)

[wpcf-date-of-injury] => Array
(
[0] => 1542067200
)

[wpcf-date-shipped] => Array
(
[0] => 1543363200
)

[wpcf-lop-requested] => Array
(
[0] => 1543276800
)

)

#1155450

Hi Mukesh,

Thank you for contacting us and I'll be happy to assist.

I performed few tests on my website and couldn't reproduce the issue that you're experiencing on your website.

Every time a post reference field value is saved for a post, it's corresponding custom field value also gets updated and is accessible in the admin area and through the code.

I did notice that when a post which doesn't have a custom field value is saved in the admin area, the custom fields for the post reference fields become available.

For example, your referral post "Trevor -" ( hidden link ) didn't have the "wpcf-attorney" value shown in the custom fields table. But after I clicked the "Update" button on its edit screen, it became available.
( screenshot: hidden link )

This suggests that the custom field values will become available for other posts too, when they'll be updated from the admin area.

Since I don't have a complete background information about how these posts were added or what post relationships or custom code existed on the website, I cannot be 100% sure why you're experiencing this discrepancy. But for further troubleshooting, I'll suggest the following points:

1. Please check your active theme's code for any custom code or script that may be automatically selecting the option for attorney selection on the referral post screens, even when the actual custom field doesn't exist.

2. Update all referral posts from the admin area and also try creating a new referral post and see if the custom field value for the attorney field becomes available or not.

If it works as expected for future and existing posts, the missing link could be a migrated, deactivated or legacy post-relationship.

I hope these points will help and let me know how it goes.

regards,
Waqar.

#1155546

Hi Waqar, thanks for that test. I actually see the same effect as your test. For Posts that do not have the post reference meta field set, when I go in the admin area and update that post, the fields are then saved. The issue is that Referrals will be created from the front-end using the CRED form and I believe that is when the Post Reference is not being saved. (the page is hidden link) which is using the referral-entry CRED Post form.

I attached the backup buddy zip of the entire site in this ticket, if you want to see the backend code.. I will do some more testing too.

#1155695

Hi Waqar,

I did some debugging and found that the Post Reference fields are in the $_POST object but the fields keys do not have the 'wpcf-' in front of them. See below, do you think that is the problem they are not saving from the front-end:

[29-Nov-2018 19:24:16 UTC] Array
(
[wpcf-lop-entry-date] => Array
(
[display-only] => November 29, 2018
[datepicker] => 1543449600
[datetime] => 2018-11-29
[hour] => 00
[minute] => 00
[timestamp] => 1543449600
)

[wpcf-lop-requested] => Array
(
[display-only] => November 29, 2018
[datepicker] => 1543449600
[datetime] => 2018-11-29
[hour] => 00
[minute] => 00
[timestamp] => 1543449600
)

[wpcf-lop-approved-date] => Array
(
[display-only] =>
[datepicker] =>
)

[wpcf-lop-requested-date-2] => Array
(
[display-only] =>
[datepicker] =>
)

[wpcf-lop-requested-date-3] => Array
(
[display-only] =>
[datepicker] =>
)

[wpcf-patient-last-name] => Long
[wpcf-patient-first-name] => Bob
[wpcf-patient-dob] => Array
(
[display-only] => February 18, 1993
[datepicker] => 729993600
[datetime] => 1993-02-18
[hour] => 00
[minute] => 00
[timestamp] => 729993600
)

[wpcf-date-of-injury] => Array
(
[display-only] => November 15, 2018
[datepicker] => 1542240000
[datetime] => 2018-11-15
[hour] => 00
[minute] => 00
[timestamp] => 1542240000
)

[chiropratic-clinic] => 276
[medical-clinic] => 276
[wpcf-clinic-city] => Irving
[doctor] => 157
[wpcf-date-shipped] => Array
(
[display-only] => November 28, 2018
[datepicker] => 1543363200
[datetime] => 2018-11-28
[hour] => 00
[minute] => 00
[timestamp] => 1543363200
)

[attorney] => 51
[form_submit_1] => Submit
[_cred_cred_wpnonce_cred_form_14] => 6294fde800
[_cred_cred_prefix_post_id] => 525
[_cred_cred_prefix_cred_container_id] => 525
[_cred_cred_prefix_form_id] => 14
[_cred_cred_prefix_form_count] => 1
)

#1160467

Any update to this?

#1160676

Hi Mukesh,

Thank you for waiting and my sincere apologies for not able to follow up on this sooner.

We've recently identified and fixed an issue which affected form submissions and legacy post relationships.

A fix for this was included in Toolset Forms 2.2 and more details are available at this erratum entry:
https://toolset.com/errata/access-relationships-after-submitting-a-form-no-longer-works/

If you'll update to Forms 2.2. and replace "cred_save_data" hook with "cred_submit_complete" hook, this issue should be fixed.

Note: Due to a different issue you reported earlier, if you'd like to keep on using Toolset Forms 2.1.1.2, that erratum page also includes a patch for a partial update.

I hope this helps and please let me know how it goes.

regards,
Waqar

#1162146

My issue is resolved now. Thank you!