Skip Navigation

[Resolved] Many to many between custom post type and user

This support ticket is created 6 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
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 12 replies, has 2 voices.

Last updated by romanB-3 6 years, 8 months ago.

Assisted by: Noman.

Author
Posts
#549474

hello,

I am trying to set up a many to many relationship between a custom post type and the WP users.

I have the CPT "Projects" and the default wordpress Users post type :
- Each Project should has at least one Project Coordinator (which is a User) ;
- Each User may be Project Coordinator for various Projects.

How may I set this up ?
Thank you.

#549577

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Roman,

Thank you for getting in touch with us. Using Toolset you cannot create relationships between Custom Post Type and Users. But I think there will be a workaround that can help in your case:

1. Each Project should has at least one Project Coordinator (which is a User) ;
==> For this you may use plugin like “Co-Authors Plus” as this will allow you to have multiple users (project coordinators) assigned to a project: https://wordpress.org/plugins/co-authors-plus/

Please note that we do not officially guarantee on working of this 3rd party plugin, I am just sharing this as I noticed a client using it and the basic feature worked fine.

2. Each User may be Project Coordinator for various Projects.
==> This is already covered in WP native, because each user can have multiple posts (projects), rest will be manageable by above plugin.

Related tickets on same topic:
- https://toolset.com/forums/topic/relationship-between-a-wordpress-user-and-a-post-type-not-working/#post-528377
- https://toolset.com/forums/topic/user-relationship-with-a-custom-post-type/#post-318013

I hope the above info helps, Thank you

#551546

Please don't close this thread yet.
Thank you.

#551938

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

yes, sure. This ticket is open and you will write us back if you need any help. I would happy to help you.

Thank you

#552148

Hello and thank you for your answer,
This solution doesn't seem to fit because the "author" of the post may not be the same than the "project manager" related to it.
Thank you.

#552264

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hello Roman,

In that case your options are quite limited to build this setup. Using Toolset it's not possible to associate a Custom Post Type to a User Profile directly. The previous given solution in this thread might be helpful, basically this method talks about adding User Fields for each WP user:
https://toolset.com/forums/topic/user-relationship-with-a-custom-post-type/#post-318013

I have tried to look for a workaround but could not find anything matching to your case. Its may be possible using some custom code to make it happen. We have some recommended list of service providers here who can help in such cases: https://toolset.com/consultant/

Thank you

#552433

Thank you. I've been thinking this again and I think I'll stay with your first solution, which is using the Author field to create the relation between Projects and Users.
Now I wonder how it would be possible for a User to choose a Project Manager among existing Users while creating a new Project ?
Thank you very much.

#552456

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Roman,

How it would be possible for a User to choose a Project Manager among existing Users while creating a new Project?

>> You may achieve this using two user roles.
Step 1:
1. Create user role as Project Manager
2. Create user role as User

Step 2:
Create a CRED Post form and display both user roles (radio options), where user can select his role (Project Manager or User)

Thank you

#552473

Hello and thank,
That's not quite this since there are a lot of Project Managers.
While the Admin creates a new Project, he must be able to choose WHICH Project Manager will Manage this specific project among registered users.
Thank you.

#552508

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hello Roman,

Unfortunately this is not possible. May be you can create Custom post type for Project Manager but again you will not use any Project Manager as a user.

Thank you

#552509

So if I understand well, there is no way to choose a post's author threw a CRED form ? Wouldn't that even be possible thanks to the CRED API ?

#552717

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

There is no way to choose a post's author threw a CRED form?
==> No, CRED form does not have any Post Author field. Usually the person who submits the form is treated as post author. Even if we have field one post can have one author only.

So it's not possible using Toolset. Its might be possible using some custom code & API but I am not sure how. You may contact recommended Toolset service providers who can help in such cases and work with you directly on this custom approach and custom code stuff: https://toolset.com/consultant/

Thanks

#555499

Thank you.
Found a workaround with user IDs.

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