Skip Navigation

[Resolved] Using access to grant ability to edit only relationship items

This support ticket is created 4 years, 8 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Author
Posts
#1607607

Hi there,

I have a CPT called Clients and another called Projects. I have assigned a one to many relationship so a client can have several projects assigned as a relationship. Here's what I'm trying to do:

-Each client can view their own client page we've created for them and also view and edit forms on each project that is in a relationship
-Easily assign a user to a client page.

Is there a way to do this in access? I've been unable to see how to restrict access only to those who are assigned as a relationship

#1608201

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As I understand, you want to display related projects assigned to the client.

If this is correct, to display the related projects assigned to the client you can create a view and display the related post.
=> https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items

In addition to that, you can also add the edit project link using the [toolset-edit-post-link] shortcode:
=> https://toolset.com/documentation/user-guides/front-end-forms/cred-shortcodes/#toolset-edit-post-link

Please check how you can add the Edit form:
=> https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/#1-create-the-form-for-editing

Please let m know if I misunderstood anything.

#1608443

Hi there,

Sorry perhaps I didn't explain correctly. I'm already displaying related items, what i want to do is make it so a user is able to view only their own client page and are only able to edit the projects that are related to that page. I'm already able to display related items as you mentioned , i'm interesting in using Access to make sure a user is able to only view their client page and edit ONLY the related projects to that page. Different users being assigned to different client pages etc.

#1610483

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - I understand what you are saying.

You mean to say that you only want to allow the users to show their client pages only. So, when you create a client, what if you make the user as a post author of that client.

So, when you display the client(s), you can filter your view by post author equal to the current loggedin user so that it will display only clients whose author is loggedin user.

Using access, you can not control the specific users but you can control the post type (Client) based on the role. So, another way, maybe you can create a custom role (allowedusers) and assign that role to the user and when you create client post you need to make sure that you assign the user with role (allowedusers) as the post author.

You should check our Membership site tutorial and see how custom roles were setup and how we are restricting the content:
=> https://toolset.com/learn/create-membership-site-wordpress-using-toolset-plugins/#add-custom-role

#1612767

It seems like i'd need to make a new role for every client no? Since multiple users need to have access to one client (say a company has multiple users and a post can't have multiple authors)

#1613603

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

With access, the possibility is you can manage with role where you can assign the same role to multiple users - but then it will work based on the role not based on the users.

So, what if you:
- Create a custom role "project-author" and when you create user make sure you assign this role to them.
- Create a page 'Company listing' as an example
- Added view that will list projects only for the current user. With this view, you can also add the company post edit and delete link as well so that current loggedin user will be able to edit/delete the company
- Create a post group and assign the page. Set permission for the correct role (project-author)
=> https://toolset.com/documentation/user-guides/access-control/limiting-read-access-specific-content/#create-or-join-access-groups

#1614037

This could work but "Added view that will list projects only for the current user. With this view, you can also add the company post edit and delete link as well so that current loggedin user will be able to edit/delete the company"

How would a project be assigned to a user so multiple users could view and edit?

#1614967

Hello,

Minesh is on vacation, will be back on Friday, you will get answer when he is back.

#1616341

In my opinion, you can try these:
1) Setup the "client" post's author as different WordPress user,
2) When user login your website, show him a page
3) In this page display a post view:
- Query "client" posts
- Filter by post's author is current logged in user
- In view's loop, display the "client" post + related "project" posts information

More help:
https://toolset.com/documentation/user-guides/views/filtering-views-query-by-author/

#1619149

How does one do it with multiple users per client? Unless there's a way to assign multiple users to a project/client

#1619437

I assume you are going to setup many-to-many relationships between
- WordPress users and post type "Client"
- WordPress users and post type "project"

Since Toolset relationships are based on post types, you will need to consider to use a intermediate post type to setup the post type relationships, for example:
1) Create a post type "Member", each "Member" post's author is different WordPress user, one user can have only one "Member" post. See below document, section "How do I prevent users from creating more than one Contractor post?"

2) Use above post type "Member" to setup the post type relationships:
- Many-to-many relationship between post type "Member" and post type "Client"
- Many-to-many relationship between post type "Member" and post type "project"

See our document:
https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/

#1628273

Hi there,

It would be a One to Many relationship not many to many. Is the process still the same?

#1628365

Yes, you are right, for One to Many relationship, the process is still the same.