Skip Navigation

[Resolved] Enabling directory users to edit their own company's posts only

This support ticket is created 5 years, 5 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
#1271625

I have migrated a directory website for the air cargo industry, taking account of relationships such as agents->airlines, airlines ->airports, airports->runways, etc... I have migrated all the data and relationships successfully, so now I want to email users in each company and them access to edit/update their own company's record. This should also include the ability for them to update/add child records (i.e an airport can edit its runway data fields, an airline can add/edit its branch offices).

I have read about post and relationship forms, and also about Access roles, and I am a long-term user of Views, Types and Layouts. I have written a custom plugin for the migration of this data, to work with all the wpcf- fields in play. I am prepared to extend that, if necessary, so that specific users of a particular role can only edit the posts they are designated. However, I can't see how to make that designation.

The site in progress is available to view at hidden link - there is a map search for airports and a directory search for all companies. There are over 8000 companies in the database of different types. I'm proposing that if we can match users to companies, via their email address, we can then store the post_id of the company (or companies) alongside its user so that the user can only edit those companies, or add new ones.

Can you give me an idea of what the best way to go about this is.
Thank you

#1271953

I'm proposing that if we can match users to companies, via their email address, we can then store the post_id of the company (or companies) alongside its user so that the user can only edit those companies, or add new ones.
Hi, the only way this can work is with some conditional logic built into your templates, forms, and posts. Access restrictions generally work based on post group, and different user roles are granted access to each post group. The limitations are each User can only have one role, and each post can only be assigned to one post group. The problems there become obvious when you're dealing with lots of different groups and roles...everything becomes unmanageable very quickly if you're trying to create unique groups for each type of worker in each company. Your idea about storing a custom field is practical, but it has some disadvantages too. For example, you cannot use Access to restrict access to posts based on a custom field value in the User's profile. Instead, you can use conditional HTML in the post template to specify which Users can see the contents inside that template. The URLs are not obscured, only the content shown within those URLs. Similarly, you can limit access to the front-end Forms to edit those posts, hide links to those posts, etc, using conditional HTML.

#1272013

Hi Christian, thank you for your response.

So am I right in thinking that if I set up a post form for editing an existing CP, I can then filter which post is editable according to its match with the user's unique ID?

And if so, then I could perhaps add a custom table to wordpress, which aligns users to their company. Or perhaps just a custom metakey/metavalue in the wp_usermeta table. Then the page template carrying the Toolset post-edit form could query that to get the ID(s) of the post(s) a user can edit.

Could this work, do you think? - is it the right way?
Thanks again.
Tim

#1272651

So am I right in thinking that if I set up a post form for editing an existing CP, I can then filter which post is editable according to its match with the user's unique ID?
You can use conditional HTML in the template to turn the form on or off based on the logged-in User's custom field value.