Navigation überspringen

[Gelöst] to display filtered results in a view depending on the logged in user

This support ticket is created vor 6 Jahren. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Dieses Thema enthält 1 Antwort, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 6 Jahren.

Assistiert von: Minesh.

Author
Artikel
#1156854

I am trying to generate a report that will show results depending on the logged in user.

The setup
A Consultant User
a Company User
A company CPT
A requirement CPT
A requirement view.

The Consultant will create a Company in the Company CPT, and create a Company User that must be linked to the Company. Question 1: How do I manage to link a user to a company CPT entry? I would like to be able to connect multiple users to a company. For a bit more complex scenario, would it be able to have a many to many relationships? This is not critical but a nice to have.

Once this is done the consultant will then add requirements to the requirement CPT that is in a one to many relationships with the Company. Many requirements for one company.

Question 2: At this stage, I want to create a view with the requirements, however, the view must only display entries for companies the "company user" is a member of. (refer question 1)

#1157651

Minesh
Supporter

Sprachen: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

Question 1: How do I manage to link a user to a company CPT entry? I would like to be able to connect multiple users to a company. For a bit more complex scenario, would it be able to have a many to many relationships? This is not critical but a nice to have.
==> Well - the thing is that you can build/create post-reationship between post types only. You can not include users to post-relationship. The alternate way is to set your user

The alternate way is to activate the "author" field for your post-type by editing your post type, that will give you author drop-down to select post author for your post.

Again, even after following the above method, you want to assign multiple authors per posts, again that is not possible, as WordPress does not support it by default. You need to find a custom way to assign multiple post authors. Find some plugin that fulfill your requirement.

Question 2: At this stage, I want to create a view with the requirements, however, the view must only display entries for companies the "company user" is a member of. (refer question 1)
==> Again, you can use post author filter with your view but this can be achieved once you successfully setup Q1 requirements.

The following link may help you:
https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/