Navigation überspringen

[Gelöst] Two relationship forms interfering -2

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

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 12 Antworten, hat 1 Stimme.

Zuletzt aktualisiert von Minesh vor 2 weeks, 3 days.

Assistiert von: Minesh.

Author
Artikel
#2848356

---------------- replacing the previous ticket, please open private reply here thanks
Hi all,
I have two different relationship forms on the same page (see picture). The first one has a parent selection, the second doesn't need it. The first one works perfectly, the second one would also, but the parent selection dropbox of the first one appears also on the other form preventing it to work because the selection is mandatory. If I delete the dropdown in the console also the second form works fine. I think this happens because Toolset generates the forms with the same code and I cannot hide the second with CSS because also the first one disappears. Is there anything I can do to work around this issue ? thanks
Regards
Nicola

#2848359

Minesh
Unterstützer

Sprachen: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

I have set the next reply to private which means only you and I have access to it.

#2848370

Minesh
Unterstützer

Sprachen: Englisch (English )

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

If you check the Events content template:
=> versteckter Link

I've added shortcode block at the top of the content template and added the following two links to it:

<a href="/event-apply-as-band/?event_id=[wpv-post-id]">  <h1>  Apply as Band </h1> </a> 
== 
<a href="/event-apply-as-musician/?event_id=[wpv-post-id]">  <h1>  Apply as Musician </h1> </a> 

We are linking the two pages you created with the current event Id.

Then, with the two pages you created:
- Apply as Band: versteckter Link
At top of the page I've added shortcode block and added the following shortcode to it to display the relationship form:

 [cred-relationship-form form='event-application-for-bands' parent_item="[wpv-search-term param='event_id']"] 

- Apply as Musician: versteckter Link
At top of the page I've added shortcode block and added the following shortcode to it to display the relationship form:

 [cred-relationship-form form='event-applications-for-profiles' parent_item="[wpv-search-term param='event_id']"]

Now, when you check on frotnend:
- versteckter Link

At top of the above event post you will see two links: Apply as Band and Apply as Mucician

once you click on any of the link it will redirected on the related page you will click the link on and it will also set the parent event automatically.

You can move the form where you want to display to whatever section you want.

#2848377

Hi Minesh,
I appreciate your effort but the original problem still appears also with this page structure: when you apply as a musician the form doesn't work because there is a dropdown (select a band) that doesn't belong to that form and it shouldn't show !! it looks like that dropdown appears independently if the two forms are on the same page or not. That form is about the event-profile relationship, not event-band. This means that there is an issue (a bug ?) I GUESS related to the fact that both are relationships where the event is parent (hidden in both forms). The issue/bug is not related to the forms, but to something else.

#2848379

Minesh
Unterstützer

Sprachen: Englisch (English )

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

Can you pleaes check now: versteckter Link

I see now profile filed. I just reset the relationship form:
- versteckter Link

You can remove/hide the fields as required.

#2848382

ok, it seems that we are getting better BUT there is no need for a dropdown here, the current user profile must be automatically selected (if there is no profile yet this form is not shown and i've placed a conditional on the page showing a message inviting the user to create one). Of course surrent user should not be allowed to select someone else's profile.
Actually we don't even need a form here, parent and chid can be automatic, is there any other way than a form to do so ?

#2848449

Minesh
Unterstützer

Sprachen: Englisch (English )

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

ok, it seems that we are getting better BUT there is no need for a dropdown here, the current user profile must be automatically selected (if there is no profile yet this form is not shown and i've placed a conditional on the page showing a message inviting the user to create one). Of course surrent user should not be allowed to select someone else's profile.

Actually we don't even need a form here, parent and chid can be automatic, is there any other way than a form to do so ?
===>
In order to connect the post we will require relationship form.

What profile post you want to see that should be automatically selected? Is it the case that you have a profile post available per user and based on the current loggedin user we need to find the profile post and that should be automatically selected?

#2848469

Exactly. The parent (event) is the current one shown in the content template, the child is the profile of the current user (current user = author of the profili custom post). Each user can have just one profile. The form just need to show a button to create the relationship. You don't need to test if a profile exists for the current user, I do this before showing the form with a conditional. If it exists I show the form, if not I show a message "please create a profile".

#2848487

Minesh
Unterstützer

Sprachen: Englisch (English )

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

I've created the following view that will return the ID of the profile post belongs to the current loggedin user.
- versteckter Link

With the page event apply as musician:
- versteckter Link

I've added the form as given under:

[cred-relationship-form form='event-applications-for-profiles' parent_item="[wpv-search-term param='event_id']" child_item="[wpv-view name='get-current-loggedin-profilo-id']"]

As you may noticed, we are pssing the parent and child item IDs so it will be selected respectively with the select dropdown.

Now, logged in as user "barbie1234" in different browser and check the following post:
- versteckter Link

I can see both parent and child dropdown are selected and now you can use and modify this form as per your requirement further.

#2848623

Hi Minesh,
passing the paramenter the forms now look good, but no posts are created. The event-profile form seems to be working (I get a "done" message from the form) but the relation is not created. I've also tested the other form event-band, the form looks good but no relationship is created. This one form seems to do nothing at all. Please check, thanks

#2849362

Hello Minesh, any news ? thanks

#2849677

Hello Minesh, please let me know thanks

#2849684

Minesh
Unterstützer

Sprachen: Englisch (English )

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

I'm not sure why relationship is not created and why its not working on site.

I've created the following sandbox site and you can auto-login to it as administrator using the following link:
- versteckter Link

If you check relationships I've two many to many post relationships:
- Gyms Books and
- Gyms personal trainers
=> versteckter Link

Where Gym is parent, so we have same parent for multiple relationship as per your strcuture.

I've created the following relationship form for post-relationship "Gyms and personal trainers" that is many to many post relationshp:
- versteckter Link

I've added the relationship form on the following single Gym content template using the "Fields and Text" block:
- versteckter Link

[cred-relationship-form form='connect-gym-personal-trainers' parent_item='$current']

Then I logged in as author user in different browser:
user: test_author
pass: Admin@999

And when I try to access the following gym single post it shows the post-relationship form at the top of the page:
- versteckter Link

And when I connect any other personal trainer post it successfully works.

I'm not sure why its not working with your setup. Maybe you need to disable all the third-party plugins and check with only Toolset plugins active and check if you able to see it works with only Toolset plugins active.

If no, you can try to replicate the same issue with above sandbox site I shared and I need clear steps that should help me to see the issue.