Is there a way to list only the users that has a specific capability, such us "publish_posts" ?
相关问题
- Display product ACF field value in Woocommerce tra
- Adding a custom button after add to cart button in
- How to add a “active” class to a carousel first el
- Setting custom order statuses as valid for payment
- change the font size in tag cloud
相关文章
- wordpress新增页面如何个性化设置
- select query in wordpress
- Get WooCommerce featured products in a WP_Query
- Woocommerce update shipping methods in checkout vi
- Change order status just after payment in WooComme
- Publishing or uploading failed. Error message: “Th
- Facebook Login With WP JWT Auth
- Wordpress development process
To select users with certain capabilities you can use WP_User_Query with meta_query parameter, because WP stores capabilities as a serialized string in user_meta table. Also remember that due to availability to have multisite installation capabilities name in user meta looks like wp_table_prefix_capabilities.
Hope it helps somebody:) Note [vars] could be substituted to array(vars), I like [] short syntax but it's supported only since php 5.4.
You can list users with WP_User_Query, but afaik you can only return different roles, not permissions, maybe that's already what you want! There's also a site where you can see the different roles in the wordpress documentation.
You can just retrieve all users. Then loop through them in a foreach. Check if the user has a specific capability then push the users to another array and use that array to list them.
NOTE: It seemed a nice quick and dirty solution at the time, but now I would recommend writing a query. I do not have the time to investigate this for you, so if the one downvoting this would be so kind to answer this question instead of downvoting an answer which was an actual help to the inquirer, that would be nice.