Skip Navigation

[Resolved] Displaying child posts according to member ship

This support ticket is created 7 years, 10 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by stefanp 7 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#397768

Hi,

I am trying to figure out how to implement your previous answer (https://toolset.com/forums/topic/displaying-content-according-to-login-information/), I finally give up and come back here for more help. I created a local copy of the website in question, and I am wondering if with the newest Toolset updates, my goal would be achieved more easily.

The project : the website is listing patients, each patient belonging to a physician. The goal here is to get each physician to connect to he website and to be able to see his own patients.

Using Types, I first created a custom post type "physician", which has a parent relationship with a second custom post type called "clinic cases". I also create a website user with a subscriber role for each physician.

However, I fail to create the right View, the ultimate goal being : if the user physician A connects to the website, he can only see the "clinic cases" post types belonging to parent-related post type physician A. And so on with physician B only being able to look at physician B patients.

Please, how would you do it ? Do I need to use more Toolset plugins such as CRED or Access to achieve this ?

Thank you for your answer

#397971

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Let me run through the broad steps involved, and then you can come back to me specific questions.

From your question I take it you want to:

- have physicians register on your site
- have physicians create "Clinic cases" and for the physicians to only be able to see their own cases

Unless there is a reason based on some information you haven't provided, I don't think you need to create both a Physician custom post type AND a physician user.

At its most basic you might have
- a page where your physicians register to create their profile
- a page where they can publish clinic cases
- a page where they can view their clinic cases

You will probably want to use Content Templates for these and combine some or all of them on the same page, and you will no doubt want to have them be able to edit their profile and cases, but the principles are the same.

So:

- create your custom post type for "Clinic cases"

- create a CRED form to add users (and another form to edit them) via the front end. You will probably want to create additional User fields so that you can store additional information about your physicians within their user profile (https://toolset.com/documentation/user-guides/user-fields/). You will need to assign them a role which enables them to publish posts (e.g. 'author'), or if you are using Access you could create a custom role.
(https://toolset.com/documentation/user-guides/cred-user-forms/)

- create a CRED form to add your "clinic cases" custom posts. Set it up so that the post author is the logged in user. When your physicians log in and use this form on the front end to create their cases, they will be the post author.
(https://toolset.com/documentation/user-guides/creating-cred-forms/)

- create a View to display the clinic cases using a post filter so that it returns only the posts of the logged in user. This is how your physicians will only see their own cases.
(https://toolset.com/documentation/user-guides/filtering-views-query-by-author/)

The physicians need never enter the WordPress backend.

I will leave the details of where you display this content up to you, but those are the basics. If you need more help then do please ask. If you have a specific problem, please consider opening a new ticket.

#398188

Hello Nigel,

Thank you for your reply, it is very thorough. Yes, I already have a plug-in for the physicians to register to the website and edit their profile if needed.

However, physicians do not add the clinic cases. Only one of them does, and he happens to be the website admin : he creates clinic cases and "shares" them with some other external physicians (dentists for instance).

To sum up, physicians can already edit their profile, change their password, etc. They only need to get a zero-level permission role, such as subscriber, to log into the website.

My problem actually lies into this : how to link clinic cases to one of these physicians/subscribers, so that when they log in, they can only see the patients that the admin shared with them. Sorry if I mislead you in my first post, or if it wasn't clear enough, but only the website admin (one physician too) is adding clinic cases, so only one author for all of them

In my mind, I had the following logical system
- create a user with a subscriber role for each physician wanting to register,
- create a "physician" custom post type, parent of "clinic cases" custom post types,
- somehow add a condition to filter the view : if user PHYSICIAN A is logged in, then only show child posts of PHYSICIAN A custom post types, but I just couldn't make it happen, must have missed something.

Is it possible to make it that way instead and, should it work, could you edit your answer according to that ? Thank you very much for your help.

#398580

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You need a way to connect your cases to your physicians.

In my mind the most logical way for this is to have your physicians be the authors of your cases, which makes setting up your views and templates more straightforward.

If you have one site admin that is responsible for creating the cases, you could have that admin set the post author to the required physician when they create (or edit) the case. The physicians need a role which allows them to be post authors (e.g. contributor), while the admin in the back end of course has access to all of the cases even though they are not assigned as author of them.

Alternatively, with your version, unless there is something else you are not telling me about, the Physician custom post type still seem entirely redundant. You want to connect the cases to a physician, with the special case where a logged in physician sees only their cases. Well, if for some reason you don't want to assign the post author to your physician users, you can add a custom field to your cases for the physician user and use that as the basic for your view queries.

Your physician custom post type seems to be an unnecessary intermediate.

#399107

Hello Nigel,

Thank you very much for your message, it's been a huge help. It worked like a charm : I never thought of using the post author as a filter for the view : I'll keep that in mind for next time.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.