Skip Navigation

[Gelöst] How To: Many-to-Many auto connect Content

This support ticket is created vor 6 Jahre, 4 Monate. 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 7 Antworten, has 2 Stimmen.

Last updated by Shane vor 6 Jahre, 4 Monate.

Assigned support staff: Shane.

Author
Artikel
#436412

Hi,

i have followed your Tutorials...

https://toolset.com/documentation/user-guides/getting-started-views/part-8-one-many-relationships/

https://toolset.com/documentation/user-guides/getting-started-views/part-9-many-many-relationships/

to make ak many-to-many relationship. All works fine.

I have a CRED Form for submitting Content. In the tutorial 9 (part: Connecting Artist with existing Events) you make the connection manualy. Is there a way to make this work within the form submiting ? So i don´t must do this manualy.
Something like...

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==xx)
    {
        //get the Post ID of the current event:
       $event_id = $form_data['container_id'];
       //update the new registration post parent field with this ID:
       update_post_meta($post_id, '_wpcf_belongs_event_id', $event_id);
    }
}

I have tryed that, but nothing happen.

#436561

Shane
Supporter

Languages: Englisch (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mirjana,

Thank you for contacting our support forum.

Normally on a CRED form there should be a field where you can select the parent.

Does this parent field appear on your CRED form ?

Please let me know.
Thanks,
Shane

#436605

Hi Shane,

thank you for helping me. No it´s not appear. I have tryed putting it in my self.

[cred_field field='_wpcf_belongs_event_id' class='hidden' value='' order='date' ordering='desc' no_parent_text='No Parent']

in frontend ill become this....

There is a problem with _wpcf_belongs_event_id field. Please check CRED form.

...but it´s not change anything.

My Setup is the Same as in your tutorial...

https://toolset.com/documentation/user-guides/getting-started-views/part-9-many-many-relationships/

Post type: Event (using different name)
Post type: Artist (using different name)
Intermediary Type: Appearance

then i have a Cred Form for Artist (only some Fields for now) with send button.

This will work if i setup event as parent from artist....with

[cred_field field='_wpcf_belongs_event_id' class='hidden' value='' order='date' ordering='desc' no_parent_text='No Parent']

and

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==xx)
    {
        //get the Post ID of the current event:
       $event_id = $form_data['container_id'];
       //update the new registration post parent field with this ID:
       update_post_meta($post_id, '_wpcf_belongs_event_id', $event_id);
    }
}

but i dont will work (auto connect Content) with this setup like in your tutorial...

Post type: Event (using different name)
Post type: Artist (using different name)
Intermediary Type: Appearance

I am working for now lokaly...so i cant show you. But i hope i have explained good.

sorry for my english ?

#436611

Shane
Supporter

Languages: Englisch (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mirjana,

The CPT that you want to do this for is it directly related to the Events CPT ?

Meaning it is not connected to it through an intermediary CPT ?

Please let me know.
Thanks,
Shane

#436616

Hi Shane,

no the 2 CPTs are connected through intermediary CPT called Appearance (like in the tutorial).

Mine 2 CPTs only have different names as in the tutorial. So for easynes i named it also Event and Artists.

It also works so that i can connect it manually...but not through the CREDform itself.

#436875

Shane
Supporter

Languages: Englisch (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mirjana,

So you are trying to automatically connect which CPT to which CPT.

This is the part i'm not understanding clearly 🙁 So you have Event <- Appearance -> Artist.

Maybe using an Arrow would help me understand which 2 you are trying to connect.

Thanks,
Shane

#436900
many2many.jpg

Hi Shane,

ill post a picture...hope this helps.

Thank you.

#437595

Shane
Supporter

Languages: Englisch (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mirjana,

This is because we are dealing with a Many to Many relationship with an intermediary CPT.

So in order for you to relate Artist to Events then you must Relate Events to Appearance and then Using that same Appearance relate it to the Artist.

So you wouldn't be able to provide the ID of an Artist for the Event but you would be able to do it for Events.

Please let me know if this helps. I might still be miss-interpreting.

Looking forward to hearing from you soon.
Thanks,
Shane