Skip Navigation

[Résolu] Views Query Filter users with Role set by View shortcode attribute?

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.

Marqué : 

This topic contains 2 réponses, has 2 voix.

Last updated by Kris Haamer Il y a 6 années et 6 mois.

Assigned support staff: Shane.

Auteur
Publications
#297000

I am trying to filter users with the Role set by View shortcode attribute. How would I achieve that with views? The query filter only allows me to set the user filter Criteria to ID or username.

Thanks.

#297228

Shane
Supporter

Languages: Anglais (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kris,

If you are talking about filtering the data based on the user's role then I'm not sure that this can be achieved. The reason for this is that the filters are done based on the attributes of the Post Object itself (see link)
https://codex.wordpress.org/Class_Reference/WP_Post

Only the attributes of the Post Object can be used in a filter.

The reason for only having the username and id only is that they can be used as the post_author attribute to run a filter.

Notice in the Post object we do not see an attribute for role.

If I am not understanding the question, please let me know and we can go from there.

Thanks

#297248

Yes, that's it. What I'm doing is showing a list of members on different pages based on their role in the company. With the current setup I needed to create a bunch of views that are exactly the same with the only difference of manually selecting the role for each view. It works but would make more sense to add more complex filter queries in the future and I could do this with only 1 view. #FeatureRequest