Let's say we have:
* 1 CPT = Companies
* 2 companies: company A and company B
* 2 user roles: company A employee and company B employee
* 3 users, 2 of them are company A employees and 1 is company B employee
Need:
* all users can see all companies
* company A employees can only edit company A post (in front-end, with CRED)
* company B employees can only edit company B post (in front-end, with CRED)
Possible without coding?
I thought, that defining a write permission for a post group would solve the problem, but there is just the read option.
If not possible:
* would it be it easier if there were only 1 employee of each company? (just wondering)
Thank you!
If only the front-end needs to be restricted, you may be able to use inline Access Control shortcodes to handle this by only showing certain forms to certain Roles. That can certainly be accomplished without code, but how depends on your site structure and how the CRED forms are placed on the page. Here's an article that discusses Access Control for page content:
https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/
Example:
[toolset_access role="EmployeeCompanyA" operator="deny"]
This content will not be shown to Users with role "EmployeeCompanyA".
[cred_form form='edit-company-b' form_name='Edit Company B']
[/toolset_access]
So if you have two different CRED forms, one to edit Company A and another to edit Company B, then you can show and hide those forms effectively with these toolset_access inline controls. Let me know if I've misunderstood the requirement, or if you have other questions about this.
Sadly not, because that's the point - I don't want to duplicate forms or layouts because they'll be all the the same, since the companies are the same CPT. Furthermore there are much more companies, than in the example with just 2.
But I guess I solved the problem in a similar way: I use conditional output to compare some current user field with some field of the company being viewed, and if they match the form is displayed, otherwise the error message. The same for the "Edit post" link.
Thank you for fast reply!