Although it might seem a silly task, I simply can't find a method to get an array of all WordPress user roles that don't have a specific capability.
With the function bellow I'm able to get all available user roles, but how can I filter those so I can return only the user roles with or without a specific capability, let's say it's the upload_files capability? Would it be doable?
function get_roles_that_cant_upload_files() { global $wp_roles; if ( !isset( $wp_roles ) ) $wp_roles = new WP_Roles(); $available_roles = array(); $available_roles = $wp_roles->get_names(); return $available_roles; } I've searched everywhere through WordPress docs and the web for a proper WP core function, which seems not to exist, not even a filter.
I was hoping to get only the user roles without the upload_files capability. Doing so, I'd use it to feed a select field within a plugin options and then I'd set another capability for the selected user roles.
I'm not a developer, so I've tried a few "hacks" without success. It seems the user capabilities are stored in wp_options table, this makes me think if would it be possible to perform a database query in order to get those results?
Any inputs appreciated.