Role based exposed filter is not showing anonymous and authenticated roles there. Can anyone tell me any method to add that roles? I've created one drupal7 view which will filter all contents based on roles not current user role. For that I've created one relationship 'author' then in view filter criteria I've given exposed author roles. But by default Anonymous and Authenticated roles are not showing there. Do we have any method to add Anonymous and Authenticated role to that filter?
That's because they are not really real roles, more just a group of users.

What I mean by this is that the relationship between users and roles is stored in the table users_roles. There is one field for uid (the users ID), and one field for rid (the role ID).

So, the admin user has a uid of 1 and also has the administrator role with an rid of 3, so there is an entry in the users_roles table like: 1 | 3.

Any other roles created and assigned will also have rows inserted into this table.

However when the admin user logs into the site there is not a row inserted into users_roles table for the "authenticated user" role. And likewise when they log out a row is not inserted for the "anonymous user" role.

The actual query used by views would be something like this:

SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created, node.uid, ur.rid
FROM node node
LEFT JOIN users users_node ON node.uid = users_node.uid
INNER JOIN users_roles ur ON users_node.uid = ur.uid
WHERE node.`status` = '1' AND node.type IN  ('article') AND ur.rid = '3'
ORDER BY node_created DESC


Here it is joining onto the users_roles table, but we know that the roles "anonymous user" and "authenticated user" don't have entries in the users_role table so it won't work.

So whilst it is possible to add these 2 roles into the select, the query that runs won't ever return anything.