Skip Navigation

[Resolved] Specific Users filter does not work how I expected

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a View of Users that should display information about only one User - the current logged-in User. However the View is currently showing all Users.

Solution: The Query Filter in this View requires you to use a shortcode attribute to pass in a User ID or IDs. If you do not pass in the ids shortcode attribute, all Users will be displayed. See shortcode-attribute.png.

You have added this View using a View widget in the Входящие и Исходящие widget panel (see cannot-use-widget.png). This will not work, because you cannot add a shortcode attribute to a View widget. Instead, you should use a Custom HTML widget to add this View in a wpv-view shortcode. Then pass the current User's ID into the Query Filter using the wpv-current-user shortcode and the users shortcode attribute:

[wpv-view name="saydbar-vkhodyashhie-i-iskhodyashhie" users="[wpv-current-user format='meta' info='id']"]

Relevant Documentation:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-current-user
https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/

This support ticket is created 4 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.

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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by Serhii 4 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1550965

Hello, help me please with the next problem:

My site: hidden link

I have created a view (hidden link) which should be displayed inside widget at sidebar - hidden link

In this View should be displayed information about a current logged-in user. But, for some reason, I get the View with information about all users.

How it should be - hidden link
What I have got - hidden link

That is my Query Filter in this View - hidden link (hidden link)

I do not understand why it does not work, because inside another View this Query Filter works well.

#1551527
cannot-use-widget.png
shortcode-attribute.png

Hello, since you only want to display information about one User, there really isn't any need for a View...unless you have already created this View for another purpose and you want to reuse it. Regardless, let's discuss why it doesn't work. The Query Filter in this View requires you to use a shortcode attribute to pass in a User ID or IDs. If you do not pass in the ids shortcode attribute, all Users will be displayed. See shortcode-attribute.png.

I believe you have added this View using a View widget in the Входящие и Исходящие widget panel (see cannot-use-widget.png). This will not work, because you cannot add a shortcode attribute to a View widget. Instead, you should use a Custom HTML widget to add this View in a wpv-view shortcode. Then pass the current User's ID into the Query Filter using the wpv-current-user shortcode and the users shortcode attribute:

[wpv-view name="saydbar-vkhodyashhie-i-iskhodyashhie" users="[wpv-current-user format='meta' info='id']"]

This technique is called passing arguments to Views, and you can find more information about it at the link below.

https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-current-user
https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/

Let me know if you have questions about that.

#1553151

My issue is resolved now. Thank you!