Navigation überspringen

[Gelöst] One-to-many-relationship & Edit post form –> part 2

This support ticket is created vor 5 Jahren, 1 Monat. 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)

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Lara vor 5 Jahren, 1 Monat.

Assistiert von: Minesh.

Author
Artikel
#1390773

I am trying to:

use this piece of code in the Toolset settings ...

<?php
toolset_snippet_security_check() or die( 'Direct access is not allowed' );

/**
 * Reset parent post ID on post edit form
 */
function ts_override_parent( $form_data ){
   
    $form_id = '4787';
   
    if ( $form_data['id'] == $form_id ){
error_log('object: ' . print_r($_POST, true));
      	// reset parent
        $_POST['@buchungssystem-selbstportrat_parent'] = '4668';
        $_POST['@selbstportrat-element-portrat-user_parent'] = '4702';
    }
}
add_filter( 'cred_before_save_data', 'ts_override_parent' );

to change the following CRED from before submission:


[credform]
    [cred_field field='form_messages' class='alert alert-warning']
    <div class="form-group">
        <label>Qualifikation Reitlehrer</label>
        [cred_field field='qualifikation-reitlehrer' force_type='field' class='form-control' output='bootstrap']
    </div>
    <div class="form-group">
        <label>Mindestniveau Reitschüler Dressur</label>
        [cred_field field='mindestniveau-reitschuler-dressur' force_type='field' class='form-control' output='bootstrap']
    </div>
    <div class="form-group">
        <label>Mindestniveau Reitschüler Springen</label>
        [cred_field field='mindestniveau-reitschuler-springen' force_type='field' class='form-control' output='bootstrap']
    </div>
    
    <div class="form-group">
        <label>Buchungssystem -- Cuteberry | ### Porträt User</label>
        [cred_field field='@buchungssystem-selbstportrat.parent' class='form-control' output='bootstrap' select_text='--- not set ---' value='[wpv-post-id item="4668"]']
    </div>
    <div class="form-group">
        <label>Load Selbstporträt für Kunden oder für Dienstleister</label>
        [cred_field field='@selbstportrat-element-portrat-user.parent' class='form-control' output='bootstrap' select_text='--- not set ---' value='[wpv-post-id item="4702"]']
    </div>
    [cred_field field='form_submit' output='bootstrap' value='Submit' class='btn btn-primary btn-lg']
[/credform]

I expected to see:

Both of the following things should change ...

  $_POST['@buchungssystem-selbstportrat_parent'] = '4668';
        $_POST['@selbstportrat-element-portrat-user_parent'] = '4702';

Instead, I got:

It's weired the following piece works

  $_POST['@buchungssystem-selbstportrat_parent'] = '4668';

but this part, will not be changed

        $_POST['@selbstportrat-element-portrat-user_parent'] = '4702';

Kind regards
Lara

#1390837

Minesh
Supporter

Sprachen: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

I see based on the code you shared that you are targetting the form with ID equal to 4787 - Can you please share details where I can see the form with ID 4787 on frontend, I mean where on what page you added that form?

#1391849

Hi Minesh,

many thanks for your answer. You can find the form here: versteckter Link
It's the third form on this page. I deleted some of the fields (in my last post) to make the CRED form code more clearly.

Kind regards
Lara

#1392195

Minesh
Supporter

Sprachen: Englisch (English )

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

Nigel contacted me that he will handle this issue with the original ticket you reported which he is handling.

So, please feel free to close this ticket. He will reply you with your following original ticket:
=> https://toolset.com/forums/topic/one-to-many-relationship-edit-post-form/page/2/

#1392835

Many thanks Minesh.