As I understand, it probably changed over the years, now it's not 'wp_capabilities'
. I looked at the core WP files, how they do it now, and found a new solution to this. Here's the code I use now:
global $wpdb;
$cap = get_user_meta( $wp_user_id, $wpdb->get_blog_prefix() . 'capabilities', true );
$cap
then comes as an associative array, for example:
{
"administrator": true
}
or
{
"subscriber": true
}
So in your case you should probably then get the keys of the array:
$caps_array = array_keys( $cap );
and then get everything from it. I needed to see if the user has the administrator role, so I checked:
if ( is_array( $cap ) && !empty( $cap['administrator'] ) ) { return true; }
I had a user ID, not the whole WP_User
object, and I didn't want to use any solution that would create the user
object. As I checked, get_user_meta
goes straight to the db to check for this exact parameter, so this should be the fastest and resource-wise route.