Skip Navigation

[Resolved] Display view based on the curent logged in user.

This support ticket is created 3 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
- 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)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 3 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#2006233

Hi

I have a user form, and I have views to display the users.
I want to filter and display the users based on the currently logged-in user.
For example,
I have two admin users who should access the view and check the registered users. (Admin1,Admin2)
What I have now is:
Two different views filtered by the organization field, and each added to a different page. So, each admin should access his page.
What I want:
One view on one page
If the current logged in user is Admin1 (display all users where the organization = Org1 )
If the current logged in user is Admin2 (display all users where the organization = Org2 )

#2006369

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Please note that you can create the custom search view for view queries post types only. You can not create custom search for user/taxonomy kind views.

Yes, you can add a query filter to filter your view results. To filter the posts by current loggedin user, you can filter your view by post author:
=> https://toolset.com/documentation/user-guides/views/filtering-views-query-by-author/#post-author-is-the-same-as-the-logged-in-user

It seems you want to filter your user view based on the organization custom field.

If this is true - you should create a user view that query your user role and add a query filter to filter your user view by your organization custom field that should be filter by using shortcode attribute. Screenshot: hidden link

The on the page where you want to display your view, you should add a conditional block to check for current user ID for admin1 and add your view with shortcode using "Fields and Text" block with view's shortcode attribute as:

[wpv-view name="user-view-filter-by-email" org="org1"]

Again, create a page where you want to display org2, add a conditional block to check current user ID for admin2 and add your view with shortcode using "Fields and Text" block with view's shortcode attribute as:

[wpv-view name="user-view-filter-by-email" org="org2"]

More ifno:
=> https://toolset.com/course-lesson/using-toolset-conditional-block/