Skip Navigation

[Resolved] Parent post relationship not saved in CRED form

This support ticket is created 4 years, 8 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
- 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 3 replies, has 3 voices.

Last updated by poM 4 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#1571035

poM

Hi,

I have a CRED form that creates a "candidature" post type on hidden link (click on "Postuler").

The first field "Annonce associée" establishes a post relationship with the current "annonce" post.

Once the form has been submitted, the post relationship is not saved anymore in the "candidature" post.

I' afraid it is linked to WordPress 5.4 upgrade.

Here is the error I have in my log :

Got error 'PHP message: PHP Warning: Creating default object from empty value in /var/www/vhosts/recrutisagency.com/httpdocs/dev.recrutisagency.com/wp-content/plugins/cred-frontend-editor/application/controllers/field_translation/command/CRED_Translate_File_Command.php on line 46', referer: hidden link

Cheers

#1571569

Hello,

I have tried the credentials you provided above, but I get this error message:
Identifiant inconnu. Vérifiez l’orthographe ou essayez avec votre adresse e-mail.
Please check it.

And the problem you mentioned above is abnormal, please check these:
1) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2020, deactivate all custom PHP/JS code snippets, and test again

2) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL and form URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1571961
#1572913

Minesh
Supporter

Languages: English (English )

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

Luo is having a holiday today. This is Minesh here and I'll take care of this ticket. Hope this is OK.

With the Toolset Form you created:
=> hidden link

I've changed the way how you added the parent field. I've added the parent field using the Toolset Generic hidden field:

 [cred_generic_field field='@annonce-candidature.parent' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
 "default":"[wpv-post-id]"
}
[/cred_generic_field]

Then I submit a new test entry using the form and I can see the parent is automatically connected to new submitted entry.
=> hidden link

Can you please confirm it works at your end as well.

#1572961

poM

Hi,

I finally solved the issue yesterday evening with the code below.

<div class="form-group hidden">
<label>Annonce associée</label>
[cred_field field='@annonce-candidature.parent' class='form-control' output='bootstrap' select_text='--- non défini ---' value="[wpv-post-id]"]
</div>

I have also managed to setup the relationship on the secondary language with Polylang installed with the following code, set in a cred_save_data hook :

$lang == pll_current_language();
$parent_id = $_POST['@annonce-candidature_parent'];
$parent_id_fr = pll_get_post_translations( $parent_id )['fr'];

if ($lang == 'en') {
toolset_connect_posts('annonce-candidature', $parent_id_fr, $post_id,);
}