Could it be posible to add a filter option to “(AnsPress) Users” widget based on user roles

3.14K viewsThemes
0

Would itĀ be possible to filterĀ “(AnsPress) Users” widget based on user roles.

This would allow to show a team of moderators or “experts” who can be followed.

This is all simple PHP, anything / everything is possible.

Hi Dima, could you give me some guidance. I am not a programmer.

Some guidance? Sure.
– Download anspress sources or use the ones in your /plugins folder
– Find some unique-looking markup / css classes in widget output, search sources for it to find where exactly it’s generated
– Find a place where it gets “list of users”
– Iterate over this list and remove every user that does not fit your criteria / or maybe just few of them are getting queried, then you’d have to either query more, or query with your criteria
– Once you got it working by modifying sources, you could either implement a snippet, if there is an easy filter to achieve it (generally AnsPress is very developer-friendly and have filters in all the places), or maybe even implement required filter yourself and commit it to github. Another option is to make a stand-alone widget plugin, requires a bit more work, but it wil be easy to distribute.

Thanks. I will look into it

Looks easy but impossible for not coders : /
I’m looking too how to show only users with certain role…
Any help (code ready to copy/paste ; ) is welcome