Skip Navigation

[Resolved] CPT editable by speific Users?

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to use Forms to allow Users to submit and edit posts. I would like to group Users by Company, and allow all Users from the same Company to read and edit all posts by all Users from the same Company.

Solution: Unfortunately there isn't a simple option that will allow you to create this type of filter. I think the simplest option is to add a custom field that holds a Company ID in the User profile, and add another custom field that holds the Company ID in each post. When each User submits content, the Company ID from their User profile could be used to set a custom field in the submitted post. Then you could filter a View by Company ID, and that would show each User content from other Users in their own Company.

Another more complex solution is to use a proxy custom post type that represents Users - something like "Employees". Each User is the post author of one Employee post. Then you can use post relationships to relate Employees and Companies. Then you can use Views post relationship filters to show and hide content based on which Company the Employee is related to. We have more information about using a proxy post type available here: https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/
See the first FAQ for more information about how you can limit each User to only one Employee post.

This support ticket is created 4 years, 11 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1446949

Hi,
First of all - My apologies for posting so many support requests. I have now started to understand the power of toolset, and hopefully I will give you guys less to work with support tickets in the future.

I am about to complete hidden link, and I have one challenge I need to solve before going into publishing state.

The site is built like this:
CPT with up to 40 posts. The posts are presented using filters that only shows posts belonging to author of the post. So user A can read / edit only posts posted by user A. When user B logs on he / she will only read / edit posts belonging to user B - and so on.

The users in this case will be a company - Company A, Company B - and so forth. I am now trying to add multiple users to the companies.

My question is: Is it possible to add multiple users to company A - so that each of these users can read / edit post A. And then do the same to Company B - and so forth.

If this is possible, where do I start 🙂 I have been testing access, but I am not capable to understand how I can combine multiple users togheter with the query filter "Post author is the same as logged in user"

#1447589

Hi, if you want to allow multiple Users to access the same post, then filtering by "Post author the same as logged-in User" does not help because by default only one author is allowed in WordPress.

Unfortunately there isn't a simple option that will allow you to create this type of filter. I think the simplest option is to add a custom field that holds a Company ID in the User profile, and add another custom field that holds the Company ID in each post. When each User submits content, the Company ID from their User profile could be used to set a custom field in the submitted post. Then you could filter a View by Company ID, and that would show each User content from other Users in their own Company.

Another more complex solution is to use a proxy custom post type that represents Users - something like "Employees". Each User is the post author of one Employee post. Then you can use post relationships to relate Employees and Companies. Then you can use Views post relationship filters to show and hide content based on which Company the Employee is related to. We have more information about using a proxy post type available here: https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/
See the first FAQ for more information about how you can limit each User to only one Employee post.

Let me know if you have questions about either approach.

#1448047

My issue is resolved now. Thank you!