I changed to current_user_can(“role-a”) and it sort of works. I have 3 rows with 3 different images.
The first row has !is_user_logged_in() and that image shows when the user is not logged in. WORKS PERFECT.
The second row has current_user_can(“role-a”) and that image shows when the user’s role is role-a. WORKS PERFECT.
The second row has current_user_can(“role-b”) and that image shows when the user’s role is role-b. CURRENTLY SHOWS THE IMAGE FOR A AND B.
Checking roles in this way is deprecated in WordPress. Try using a capability instead of a role name in current_user_can().
If you must use roles, define this function in your theme’s functions.php:
function current_user_has_role( $role ) {
$user = wp_get_current_user();
return $user->exists() && in_array( $role, $user->roles );
}
Then use that function instead of current_user_can().