Skip Navigation

[Resolved] relationship between users and custom post types

This support ticket is created 4 years, 10 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 5 replies, has 2 voices.

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

Assisted by: Luo Yang.

Author
Posts
#1274023

Tell us what you are trying to do?
I want to create a custom "Wishlist" system for my site. So I need a many-to-many relationship between users and custom post types.
If you have better solutions or better workarounds, please share.

Is there any documentation that you are following?

Is there a similar example that we can see?
Yes, like all the wishlist options available on so many websites.

What is the link to your site?

#1274059

Hello,

I suggest you setup two custom post types, for example:
- Members
Each wordpress user can have only one member post, and member post's author is different wordpress user
- Wishes
Setup many to many relationship between post types "Members" and "Wishes"

It can setup relationships between users and post types, see our document:
https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/
How to Create Custom Searches and Relationships for Users

#1274485

Thank you for your reply.
I still don't understand how it is going to work. How users can use this relationship and assign "wish" status to some product or article? And how this "Wishes" post type is going to represent real products or articles (other post types)? How are they going to be connected to each other? In the backend I know I can use many-to-many relationships to connect these together, but don't know about frontend.
And at last, don't you think this approach will make the database heavy and slow in long term? Letting users create this amount of relationships will make website slow in future.

#1275343

In front-end, you can use Toolset relationship form to setup the many-to-many relationship between existed "Members" and "Wishes" posts, see our document:
https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/

Toolset post type relationship is using another database table, each relationship is one row of data, so it won't make the database heavy and slow in long term.

#1275403

Dear Luo,

Many-to-many relationship between "Members" and "Wishes" need both "Member" and "Wishes" to be custom post types (If I understand correctly). Is there a way to create many-to-many relationship between real "Users" and "Wishes"?

And one questions about the form. Is it possible to create this many-to-many relationship in frontend without the form? I mean like other websites, just by clicking on the yellow star near the product name? Filling a form for adding something to your wishlist is a bit strange. Do you agree?

#1275447

Q1) Is there a way to create many-to-many relationship between real "Users" and "Wishes"?
No, there isn't such a built-in feature within Toolset.

Q2) Is it possible to create this many-to-many relationship in frontend without the form?
It needs custom codes, for example, you can setup a HTML link, pass two URL parameters:
- Members post ID
- Wishes post ID
Then use function toolset_connect_posts() to connect above posts with specific post type relationship:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

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