Skip Navigation

[Resolved] Teams and CPT

This support ticket is created 3 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.

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by nestorC-2 3 years, 10 months ago.

Author
Posts
#1955985

Hello

Point 1

I have Team CPT, Project CPT, and CPT supplier. The relationship between Team and Project is many to many, project and team many to many

I want to achieve project workspace privacy funtionality in terms that when user access to a project CPT page can see it only if is part of any team related to the project.

Membership Role: This is not a solution, because if I assign an editor capable to read CPT Project could read all other projects that do not belong to him

Group WordPress Plugins: They create separated groups not related to CPT or let you assign as taxonomy field to a CTP as a group, but is the same issue as Membership Role, could read all project that does not belong

Toolset conditionals: I could set up a condition as the main block in the CPT template but I can't find a way conditions can be related to CPT relationships like the following

View loop Project-Teams
View Loop Tems-Supplier (nested)
current user.id = supplier.author.id
Main block with all page content

Point 2

I have Project CPT, Task CPT, and Section CPT. Tasks and Section are related many to many

I want to show in the project

Section
Task

But I can't find a solution because nested views are not supported

Could you please help to find a solution for those 2 points?

Thanks

#1956479

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You are right that the solution would need to use conditional display, a role-based solution or similar could not work.

But there is no way that you can add such complex conditions using the UI. You can use custom functions in conditions, and that's the route you'll need to go down.

Write a PHP function that gets the related teams for the current post, and checks if the author of those teams matches the current user id.

You have to register the custom function for use in conditionals at Toolset > Settings > Front-end Content.

You'll need to use the relationships API, specifically toolset_get_related_posts (https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts).

As for the second question, I take it Sections are related to Projects? So you can show Sections belonging to a Project easily enough, and—yes—you need nested View to display the Tasks belonging to each Section.

Support for nested Views should be coming later this year, but in the meantime you need to use the legacy Views interface to use nested Views. Are you familiar with that at all?

#1958099

Thanks for that, it's helpful. I will check the legacy view