Skip Navigation

[Resolved] Add post relationship to a post on the front end

This support ticket is created 5 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 13 replies, has 3 voices.

Last updated by katerinaA 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1256317

Hi there,
I'm new to the post relationships so I need some... conceptual help!

I have created 2 Custom post types. I have also created a post relationship between them.
There are also Users who can create and edit the above posts, on the front end.
So far so good!

My need is as follows:
When visiting one Post (I have created a content template) the User should be able to use a search form (searching the posts from the other Post Group) and then add the relationship to the current post, for one or more posts he found through this search.

My site is on a development server and can only be accessed by adding the ip to the hosts. Is this possible for you to check?

Thank you very much

#1256521

Hello,

I assume you are going to connect existed posts in front-end.
Yes, it is possible, please follow our document to setup the relationship form, so your users will be able to search posts in a input box(select2 feature), and connect it with another specific post, see our document:
https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/
How to Build Front-End Forms for Connecting Posts

#1266943

hi again,

Thank you for your instructions... I am afraid I need something more specific than the general info...

The site is public now and I have created an account for you.

We want to create a relation between posts from different post groups the following this procedure:

This is the content template page of one post hidden link
I would like to click the button "REAGENTS" and initiate a search for the posts of another group, in order to find one and create a relationship with the post that I started the search from.
Is it possible to create a relationship, only to the post where the search started from, by clicking on a button, next to each result?

I know it is complicated as I describe it but it is simple in the concept actually!
Where can I send you a username and password please?

#1267943

Minesh
Supporter

Languages: English (English )

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

Luo is on vacation. This is Minesh here and I will take care of this ticket. Hope this is OK.

Well - the link you shared needs access details. Can you please share login details so I can check what you want exactly and somehow its possible with Toolset or not.

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

#1269193

Minesh
Supporter

Languages: English (English )

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

Ok - I clicked on the button "REAGENTS" and selected one of the options from the drop-down and clicked on search and it shows me the following results:
=> hidden link

Do you mean that you want to connect the one of the selected post with what post?

#1269285

The page hidden link where the REAGENTS button appears, is an "Account" post (taxonomy). I would like to related this post (Account) with a "Reagent" post from the results on this page hidden link

#1270399

Minesh
Supporter

Languages: English (English )

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

Well - as I understand, you want to connect the found post with the search result with the following URL?
hidden link

Have you created any relationship form?

More info:
=> https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/
=> https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/creating-new-connections-between-related-posts/

#1274945
swa005.JPG
swa004.JPG
swa003.JPG
swa002.JPG
swa001.JPG

Hi,

The scenario below explains exactly what I want to do.

Step #1
I choose an account from the accounts page:
hidden link

I choose "Mayo Clinic". (see swa001.jpg)

Step #2
From the "Mayo clinic" account page I choose to add a "REAGENT" (see swa002.jpg)

Step #3
In this page I can see all the reagents and I have a "Drop Down" filter to narrow down the reagents list based on the their category.
(see swa003.jpg)

Step #4
After finding in the results list the appropriate reagent (in our case "Tumors markers panel: SSC"), I have a button "View Details" which opens a new tab with reagent info page.
(see swa004.jpg)

And now is the step that I want you to help me. I want an "Add" button right next to "View Details" button which will make a relation between the account ("Mayo Clinic") and the reagent (in this case the "Tumors markers panel: SSC" reagent).
(see swa005.jpg)

How can I produce such an "Add" button?

(I have created a relation form and you can see it in the Reagent info page.)

Thank you.

#1275585

Minesh
Supporter

Languages: English (English )

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

As I shared the following docs before - to connect the post you need post relationship form:
=> https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/
=> https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/creating-new-connections-between-related-posts/

You need to create the relationship to connect the post, have you created the post relationshp between your post types from:
=> Toolet => Relationship

I checked that you have created the many-to-many post relationship between Accounts and Reagents.

In order to track what account you selected, in this case ("Mayo Clinic"), we need that ID to track what account you selected before from Step #1 as when you are on Step #4 we do not have any identification when we come at Step #4 that what account you selected.

So, I've edited the following content template and modify the "REAGENT" link as given under:

<a href="<em><u>hidden link</u></em>;">REAGENTS</a>

Where as you can see we are passing [wpv-post-id] with url param related_id.

Now, when you are on reagent search page - you will have ID of account to which you want to connect to:
=> hidden link

I would like to know here which relationship form you want to use to connect the posts now?

#1275765

Minesh! A picture is worth a thousand words...
This is what I was looking for, the url param related_id!
Well, now I don't know how to use the parameter in the relationship form, so if you can please add the "FINAL Reagent to Account ADD Relation BUTTON" to the search results, I believe I won't need anything else!!!

THank you so much for the help... You are always saving me!

#1275777

Minesh
Supporter

Languages: English (English )

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

#1275801

yes! it is this one: "FINAL Reagent to Account ADD Relation BUTTON"
I just added it to the results... but it not working as it should...

#1275833

Minesh
Supporter

Languages: English (English )

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

Can you please check now. I've added the relationship form as given under:

[cred-relationship-form form='final-reagent-to-account-add-relation-button' parent_item="[wpv-search-term param='related_id']" child_item="[wpv-post-id]"]

Where:
- we mentioned the parent and child item.

When you click on submit it should connect the posts. You can change the submit button name as required.

#1275929

My dear Minesh, thank you again for your full support. I love toolset but without your help my sites would be poorer!
Thanks again for all your help 🙂