Skip Navigation

[Resolved] Relationship form

This support ticket is created 3 years, 11 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
- 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/Hong_Kong (GMT+08:00)

This topic contains 20 replies, has 2 voices.

Last updated by Luo Yang 3 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#1603007

Hi,
I am referring here to my previous support ticket #1562907, regarding the implementation of a "Members Only Favourite Artworks Collection" Feature. Please read that previous ticket forst, in order to get the context of my question below.

This is where I am at today :
- I have setup the Many-to-many Relationship between the Custom Types "Member" and "Artwork".
- also setup the Create Member Post Form, which allows a registered User to create a unique Member Post.
- also created Page (/collection-de-membre/), with the View displaying alternatively the Related Posts View (not yet finalized) listing the related Artworks if the Query Filter finds a Member Post which Author IS the registered user, or the Create Member Post Form if no Member Post exists by the registered user.

I am now seting up the Relationship Form for connecting an existing specific single Artwork Post to the current Member/User :

Issue # 1 : Connecting Artwork to Member, from the Artwork Single Template
- I have en Elementor Single Post template for the Artwork, displaying the detailed information (Custom Fields) of a given Artwork :
for example : hidden link
- on that Elementor Single Template, I want to insert the link/button to the Relationship Form which has to connect this current Artwork Post to the current Member Post

I have read the following docs :
- https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/
- https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/
- https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/#how-do-i-prevent-users-from-creating-more-than-one-contractor-post

I want to connect the current Artwork to the current Member. Questions :
- do I have to configure the link/button to the relationship Form, so that it's Url contains a parameter like the Artwork Post ID : [postID] ?
- if the parameter is the way to do it, how do I get that parameter in the Relationship Form, in order to pre-populate the Artwork field ?
--- is there a shortcode, something like [post_ID] or [param_post_ID] or [wpv-param-post-id] ?
- is there a more obvious/simple way to do this connection ? Have I missed something ?

I will put the Relationship form into an Elementor Popup, which will simply close itself after the submission of the Relationship Form, so that the user can browse to other Artworks in order to put them into her Members Only Favourite Artworks Collection.
To see the result, meaning the newly connected Artworks in her collection, the user will click the main menu item "My Collection", which displays the page with the Related Posts View (mentionned above).

Issue # 2 : similar, but from the ArtWork Custom Search View Page
I also would like to put the link to the relationship form next to each item in the View displaying the results of the Artworks Custom Search (on the page : hidden link) : Question :
- is there a shortcode to refer to the current Artwork/item ?
- could the link look like this : /favorite-popup?id=[wpv-post-id] ?

Issue # 3 : Direct connection
Furthermore, is there a way to directly submit the creation of the connection Artwork-Member with a PUT request, without the extra step of having to submit the Relationship Form on a page/popup, separate from the Artwork Single Post Template ?

Thank you for taking the time to read all the above, and to help me with those issues.
Francesco De Grandi

#1603693

Hello,

Thanks for the details, I can get your website credentials from your previous thread:
https://toolset.com/forums/topic/make-user-able-to-create-her-own-collection-one-of-artworks-many-view/

And I am checking it in your website, will update here if there is anything found

#1603901

I have tried these in your website:
1) Create a conten template "relationship-form-ct":
hidden link
Display the relationship form shortcode
[cred-relationship-form form='formulaire-de-favoris' child_item='$current']

2) Create a post view "My member posts":
hidden link
Filter by:
- Select posts in a Membres Oeuvres relationship that are related to the Post where this View is shown.
- Select posts with the author the same as the current logged in user.
in section "Loop Editor", within shortcode [wpv-no-items-found] ... [/wpv-no-items-found]
display the relationship form link:
[cred-relationship-form-link form='formulaire-de-favoris' child_item='$current' content_template_slug='relationship-form-ct']Connect with my member post[/cred-relationship-form-link]

3) Edit the post
hidden link
in section "Identité", add above view's shortcode:
[wpv-view name="my-member-posts"]

4) Test it in front-end:
hidden link
click link "Connect with my member post"
hidden link
But the content template does not work in your website, it does not display the relationship form at all, so there should be some other compatibility issue in your website.

I suggest you check the compatibility problem: deactivate all other plugins, and switch to wordpress default theme 2020, and test again.

If you need more assistance for it, please backup your website first, I need to deactivate plugins/theme in your website.

#1604009

Hi Luo,
I think the Template is not working because the Relationship form has to be put into an Elementor Page or Template or Popup - here a Page since it is not supposed to be attached to any Content (it clearly visible in your Template : nothing is checked).
What I do not understand though is how your template is built - where is the actual Relationship Form?

#1604021

... continued:
So, before you do your tests and de-activate plugins and themes etc. allow me to try by putting the Relationship Form "Formulaire de Favoris" into en Elementor Template, not connected to any Content.

If it does not succeed, then I will backup the site and you will be able to proceed with your tests.

#1604177

...continued:
OK, I got the Relationship Form into an Elementor Template "Mes oeuvres favorites".
BUT the [cred-relationship-form-link] does not work. I think it is because the attribute "content_template_slug=" only refers to Toolset Content Templates. NOTE : I commented out the [cred-relationship-form-link] you had previously (see the "My member posts" View)
Question:
- Is there a way to have the [cred-relationship-form-link] point to a Page ?
--- > here it should point to the Elementor Page "Mes oeuvres favorites" , shortcode : [elementor-template id="10165"]

I also understant that the attribute " child_item='$current' " refers to the current Artwork : an answer to my previous question about that reference, right ?

#1604317

...continued :
I really think that the problem lies with the fact that the Relasionship form is not in an Elementor Template :
- In Toolset Settings > Assistance de thème pour modèles de contenu : I introduced the 'us_load_template' function
- Front test : l'Ancêtre : clicking the link (yours) executes the connection and reloads the page with 2 links :
--- Member Name > lands on an empty page : because the Member post you made is not on an Elementor Page
--- Delete this connection > /# : leads nowhere since, I guess, it is not yet configured...

OK Site is backed up. You can proceed with your teste

#1604467

...continued :
Sorry, Luo, for this continuing Saga : I have been reflecting on your last message, and I wonder how you will be able to test if you disable the Page Builder Plugins - Elementor, Elementor Pro, Unlimited Elemments; because without them a lot of things will not be displayed - f.i. the "L'Ancêtre" Artwork Post, on which the Relationship Form Link is set...
Further, the Theme I use is the Hello Theme for Elementor, which is practically empty : the site is built with the Elementor Theme Builder, which creates Headers, Footers, Single Post Templates (especially for Custom Posts). I am afraid that switching to default Theme 2020 will make mostof these elements desappear...

But I apologize for nottelling you earlier that I am very grateful to you for creating the "relationship-form-ct", the "My member posts" View, the relationship form link. I really appreciate your help.

Honestly, I would not know how to go about the tests that you propose : I am still new to Toolset.
So I am quite stuck roght now. Thank you for telling me how you are going to proceed for the tests.
Best regards,
Francesco De Grandi

#1605171

I am checking it in your website, will update here if there is anything found.

#1605433

I have tried these in your website:

1) Create a fresh new relationship form "formulaire-de-favoris-2":
hidden link

2) Edit post view "My member posts":
hidden link
in section "Loop Editor", line 13, display the relationship form shortcode directly:
[cred-relationship-form form='formulaire-de-favoris-2']

Test it in front-end:
hidden link

The relationship form does not display correctly: No HTML form tag or parent/child select dropdowns.

It should be able to work as in the normal page:
hidden link

And the Toolset content template does not work in your website too, so there should be some compatibility problems in your website.

Toolset relationship form does not support using URL parameter as default value, you can edit above relationship form:
hidden link

click and edit the parent/child field, there isn't such an option to set the URL parameter.

Since Elementor plugins are required in your website, I suggest you follow our document to setup a content template for single "Oeuvres" post, and design it with Elementor editor:
https://toolset.com/documentation/user-guides/using-toolset-with-elementor-page-builder/create-templates-for-custom-post-types-with-elementor-and-toolset/

Then display the post view "My member posts" in above content template.

If you don't want to debug in the live website, since it is a compatibility issue, you can also provide a copy of your website in below private message box, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1605879

One more thing :
- when building the Elementor Single template for the Custom Type "Oeuvre" (the one to display "L'Ancêtre" page), I did follow the instructions it eh docs https://toolset.com/documentation/user-guides/using-toolset-with-elementor-page-builder/create-templates-for-custom-post-types-with-elementor-and-toolset/ .
If not, I could never built it, with all its details (left sidebar). I doubt that the problem lies there.

My suspicion is that maybe there is another Toolset template, a Loop template for one of the views, conflicting with the one for the Relationship Form.

Just in case the previous .zip file did not contain the whole site data (as I mentionned, I had some Duplicator Warnings), here ia the Google Drive link to the second (manual) download :
hidden link

Thank you for your efforts to resolve thisissue : I hope the solution will be useful to other Tooset users.
Best regards,
Francesco De Grandi

#1606539

Thanks for the details, I am downloading the files, will update here if there is anything found

#1606833

I have tried it with your duplicator package, after trash the Elementor template "Oeuvre standard", it is possible to design the single "Oeuvre" post with Toolset content template, but you will need to design the new content template manually with Blocks editor or Elementor editor.

And I have tested it in my localhost, the relationship forms works fine in content template, please backup your website, then update here, I can setup a demo in your website. thanks

#1606903

Hi Luo,
Thank you for testing locally. I have the following questions regarding your results :

1. Why would I have to build a new Single Oeuvre Template in Elementor editor ?
I do understand that a Toolset Single "Oeuvre" Content Template would work with the Relationship Form, when there is no Elementor Template assigned to the same content (meaningthe same CPT "Oeuvre") : in this article https://toolset.com/documentation/user-guides/using-toolset-with-elementor-page-builder/create-templates-for-custom-post-types-with-elementor-and-toolset/, at the end it is stated that :
- "If you are using Elementor to design templates for your custom post types, do not assign a Content Template and an Elementor Template to the same content."
- and "Also, do not insert an Elementor Template into a View’s Loop Item or Content Template. If you need to use an Elementor Template in the Views Loop, add it directly within the wpv-loop tags. At the same time, make sure that the posts in the Views Loop are not using Content Template for styling."
Maybe the reason that the Relationship Form does not work within my Single "Oeuvre" Template is because, when assigning, it calls a CPT Oeuvre and uses the relationship-form-ct to display/style it, and this is conflicting with the Elementor Single "Oeuvre" styling...

2. Also, I noticed that the Relationship fom itself displays 2 dropdowns : one for the "Member", and one for the "Oeuvre", under the link. In terms of UX, it is quite redundant : since the Member IS the registered user, it does not even need to be displayed,let alone chosen. The same thing goes for the current "Oeuvre". The only thing that the user has to see is the button, which simply should say "Put this Oeuvre into My Collection".
So is it possible to reduce the Relationship Form to it's link/button ?

You see, that Single "Oeuvre standard" Template of mine is very elaborate, and relies on quite a few Elementor fieatures, especially for Tablet and Mobile (which display things in a different Layout), and the magnifying lense feature, which is an Elementor Widget I designed (with the Unlimited Elementor plugin).
I am not sure that I can rebuild it identically with the Blocks editor. I took me quite a number of hours/days to perfect, so I am not ready to trash it.

Thank you for answering first the 2 questions above. Then we'll see about the demo on the site as you suggest.
Best regards,
Francesco De Grandi

#1607895

Q1) Why would I have to build a new Single Oeuvre Template in Elementor editor ?

In order to make the content template and relationship form working in your website, you will need to trash the Elementor template "Oeuvre standard", the Elementor template "Oeuvre standard" take over the post content of single "Oeuvre" post, and conducts the problem I mentioned above.

According to our support policy: We cannot always fix compatibility issues arising from third-party plugins and themes.
https://toolset.com/toolset-support-policy/

If you don't need to use Elementor editor to design the content template, then you can try with Blocks editor, this will be able to avoid compatibility issues.

Q2) So is it possible to reduce the Relationship Form to it's link/button ?

Yes, it is possible to setup the default value of parent/child select dropdown by setting the form shortcode attribute: "child_item" and "parent_item", for example:

[cred-relationship-form form='formulaire-de-favoris' child_item='$current' parent_item='12345']

Then use CSS codes to hide the parent/child select dropdown, so users don't need to set the values in parent/child select dropdown, just click submit button, and setup the relationships between "Oeuvre" post and "Member" post.

Please update here when your website is ready for setting the demo, thanks

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.