Skip Navigation

[Resolved] User CPT, user folders and views

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 2 voices.

Last updated by Beda 5 years, 2 months ago.

Assisted by: Beda.

Author
Posts
#1345291

Last year I was asked to build a membership site (of sorts) and I sought some advice on it. You can view it here https://toolset.com/forums/topic/user-control-and-privileges/

The project was put on hold but it's now back on the radar. I can give more detail but I have some questions, so here goes...

My client is an insurance broker. He has a small number of customers. The cost of insurance broking packages/websites is cost-prohibitive. That's why a membership site of sorts is a better fit. My client wants to upload documents related to each policy for each customer. They should be 'viewed' within a folder hierarchy (think Dropbox or Windows Explorer).

When a customer signs in, they should see 5 basic folders: Policies, Claims, Correspondence, Accounts and Reports. If a customer clicks on Policies, they should see a further list of folders such as Engineering or Motor Fleet. If the customer clicks on one of these folders, they should see a further list of folders such as 2019, 2018, etc. Within each of these folders should be the documents that can be viewed/downloaded. The same principle applies to the Claims folder and (to a lesser degree) Correspondence, Accounts and Reports.

My thinking was this:

1. Create a CPT for the 5 basic types of document (Policies, Claims, etc.)
2. Fields for each of these to store essential information (document title, upload field, etc)
3. Custom taxonomy for each CPT ie., the Policies CPT could have 20 taxonomies (such as Engineering, Motor Fleet, etc.
4. Custom taxonomy or tag for year (some documents may be added 6 months before or after a policy is "active")

It goes without saying that I'm open to suggestions if there's a better way to do this (maybe a field for year instead of a taxonomy?) but I thought filtering by taxonomy would be better.

Now, on to the questions...
1. What's the best way to go about assigning the documents to a customer? In some instances, there may need to be two customers assigned to a document. I had thought about using the Author field but that would restrict it to one customer only (other than an admin).
2. How should I 'create' the folders for each policy, claim, etc? My working assumption is that this would be a View that would do the following:
a) Find all CPTs assigned to the customer
b) Filter those CPTs accordingly (Policies, Claims, Accounts, etc)
c) Filter those CPTS according to taxonomy (Motor Fleet, etc)
d) Filter those sorted CPTs according to date (be it a field or a tag)
e) Render the View as a folder in each instance
Again, my working assumption is that this would be a combination of views/filters and design/CSS issues.

It will all be done (from an admin perspective) via the backend. For the customers, it would all be viewed from the front-end.
Any advice/comments/criticism gratefully received!

#1345299

Let me see if I can share some experiences and advise next steps.

I'll use your text as a base to reply on each aspect.

1My client is an insurance broker. He has a small number of customers.
- I would consider Toolset Forms to let those customers become WordPress Users on the Website. Toolset Access can then help control these users to let them do and see only what's allowed.
Consult https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-registering-users/ and https://toolset.com/documentation/user-guides/access/

2. My client wants to upload documents related to each policy for each customer.
- This will happen in the backend, so likely all that's needed here is a Post Type and fields to upload the documents.
Consult https://toolset.com/documentation/user-guides/using-custom-fields/ for this

3. When a customer signs in, they should see 5 basic folders: Policies, Claims, Correspondence, Accounts and Reports.
- At this point I do not think you need anything dynamic yet.
- You know a limited set of options should be available to click only, (Policies, Claims, Correspondence, Accounts and Reports). Hence you can just add this as HTML to a Content Template for example, assign that to a page, and lead every customer to that page at first.

This will be the same as well if you work with dynamic content, this main dashboard will be created as a static element.

4. If a customer clicks on Policies, they should see a further list of folders such as Engineering or Motor Fleet
- Now here we could have a limited amount of such "policy types" or "claim type" etc, but I assume here you cannot control what's happening: your client may add hundreds of different "types" of policies or claims.
- Hence, I suggest to use a Taxonomy here, with which you can classify each policy, claim or other thing as "engeneering" or "motor fleet" etc.
- This would then allow, to create a View, that displays ALL terms (kind of policy) used for polices, when the user clicks "policies" on the main dashboard.
- Again here, you can design with HTML the output of that, so you get a nice folder-like look, for example, of all those taxonomy terms used for policies.

5. Let's say you then click on such a taxonomy term folder - you can repeat the same game as before, pass a URL parameter to the link clicked and lead to a page with a View that displays all policies posts under that term passed by the URL parameter. You can of course go a step deeper again, and group those by dates (post publish date) by repeating the process of creating a list of date ranges, that lead to a page by passing URL parameters that can be read by the View to filter your posts.

I suggest to consult the Views DOC for nesting Views, and the general DOC here:
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/
https://toolset.com/documentation/user-guides/display-lists-of-posts-and-create-custom-searches/

6. What's the best way to go about assigning the documents to a customer?
Since you will need eventually the same document for many users, as you mention, you cannot use the Authorship - that would be the easiest though. So if you can avoid this need at all go without it. However if there is no other possibility I suggest either this approach here https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/, or eventually a custom code, that allows creating a field populated with users to related to the post. This latter requires custom code we cannot provide, hence I'd go with the suggested documented approach of mimicking the user to a post type as explained in the DOC.

I would suggest to start with that:
determine if it's needed to have different customers on the same documents
If yes, proceed with https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/
If no, proceed by creating the Post Types you need, and taxonomies associated to it.
Add the fields to the post types, and create a few dummy posts.

We can then work on the Views together with a few examples, if you have an online staging site, or I can instruct you step by step once required.
I enable a private reply in case you want to submit access to a testing site.

#1346205

Appreciate the assistance on this Beda. I'll have a look through this and update you.

If anybody has any other suggestions or wants to contribute - feel free!

#1346911

OK, please let me know when/if you have doubts or get stuck in the process, you can also always open a new ticket.

It's actually suggested for particular questions or problems, so we can attend you faster.
If you have more "generic process" questions we can handle them here.