Skip Navigation

[Resolved] User control and privileges

This support ticket is created 6 years, 1 month 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)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 6 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1150775

I'm building a prototype of a membership site that will work thus: an admin can upload a PDF document (custom post type) and make it available to a customer (individual user). The only users that should see that document are the admin and the customer in question. The admin can do other functions (such as create/add a customer). There are multiple types of documents (controlled by a custom taxonomy). To keep things simple, I'd prefer to do this from the front-end but will happily do use the back-end if needs be.

My issue is with the relationship between the customer and the document. Is it sufficient to rely upon the Author field and assign the document to the customer by 'changing' the author? I could then generate a view based upon the Post Author for the customer to see their documents. Or is there a way to create/add a user and assign it to a document using a CPT? I'm at a bit of a loss.

#1151117

Hello,

I suggest you try with custom CPT workaround, for example:

1) Create a custom post type "customer", setup each "customer" post author as a individual wordpress user, one user can have only one "customer" post.

2) Create post type relationship between "customer" and "PDF document"
- if one user can view multiple "PDF document" posts, and one "PDF document" post can be viewed by multiple users, you can use many-to-many relationship
- if one user can view multiple "PDF document" posts, and one "PDF document" post can be viewed by only one user, you can use one-to-many relationship
https://toolset.com/documentation/post-relationships/

3) Create a page as customer dashboard page, in this page create a post view, query "customer" posts, filter by:
Post author is the same as the logged in user

In view's loop, display below child view:

4) Child post view, query "PDF document" posts, filter by the post type relationship(step 2), and display the PDF file link
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items

#1151267

Thanks ever so much for the reply. Correct me if I'm wrong, but wouldn't this mean that I would have to create each WordPress user individually and then assign it as an author to the CPT "Customer"?

I suppose what I'm trying to do is combine the two and 'automate' the process, ie. create a WordPress user and CPT in one process.

#1151518

Yes, it needs to create each WordPress user individually and then assign it as an author to the CPT "Customer", and you can setup a post form let your user to create the new "Customer" post, see our document:
https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/#how-do-i-prevent-users-from-creating-more-than-one-contractor-post