Build a project management tool, where the single view of the CPT "Project" show everything segmented by 2 variables: user role and some access condition.
In the single view i accomplished everything i wanted so in this part i'm ok. What i've accomplished so far:
1- The single page of a project show different informations depending on the user role.
2- When a user tries to enter to a project where it doesn't belong it can't enter and is redirected to another page.
The challenge i'm trying to solve right now is that i want to have more than 1 user assigned to every single project, so i want to restrict the single page to a company, and then assign users to that company.
The access problem i solved it with "Access Groups", using them as every single company, deleting all user roles and assigning specific users to the access group. The solution works fine for the single page (if the user doesn't belong to the group is redirected to an specific template), but not to loop through all the projects, because each client can see every project in the platform.
Without this solve i can't achieve my clients to have their own profile and be able to see only their specific projects as a list, and to have more than 1 user per project (so assigning the project to an author is not a solution).
I expected to see:
A list where the user see only the projects that are correlated to the roles where the user belongs.
I need a way to create a filter that can display only the projects where the user have access to read. In that way i can simply use Access Groups as Companies to restrict access, and filter the inside contents with user roles. This would be a perfect solution for the platform, because it could be super flexible to even identify an user by more than 1 user role.
Instead, I got:
[Wrong] A list of every single project [Here i need a filter that Views doesn't have]
[Ok] Access control to more than one user per post.
[Ok] Segmented content by user role
Access plugin does not work on View Loop items, this thing would need custom code to make it work. For the other things, I am not sure how your Companies are added to display on the site or how they are currently displaying their profile pages. but I would imagine or suggest following steps in this case and there are two suggested methods and you can use anyone which is suitable to your setup:
Method 2:
1. Create 2 Custom Post Types using Types plugin = Company (Parent), Projects (Child)
2. Make parent child relationship between company and projects using Types.
3. Then use wpv_filter_query hook to create a custom function that will pass company_id as an attribute to the View’s shortcode:
-- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
Thank your for your answer. I still don't have enough knowledge to modify php as it's required here, and giving it a second thought is not a great idea because i'm not using Toolset's strenghts. Right now, because of time i think both of the methods you are proposing are fine, but i will use a combination of the 2. I thought about it and i think creating a CPT for a user role is the best way to go because filtering will be easy (by author, or by many to many to display the company related to the role, projects, services, etc.). I just have to worry about the access to the taxonomy and is a lot more maintainable.
Thank you
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.