Is it possible to filter out nodes with respect to current user role? For example, I want to create a view where users can see the all the published nodes as well as the unpublished nodes they have created. And if current user is a site admin, he should be able to see all the nodes. Is it possible using views?

1 Answer 1


Yes, you can use node "Author uid" as the "Contextual filter" in the views and can set default value as "User id from logged in user" or "User id from URL" for the "Author uid".

Setting Author uid as the contextual filter

If you will select "User id from logged in user", then it will display the node created by the logged in user or if you select "User id from URL", then it will display the node created by the user id from the URL.

Regarding, displaying node published and unpublished, you need to set permission for user role to view "unpublished own nodes", so user can view his unpublished node.

For the site admin user, he can only view the node created by him. If you want to display all nodes to site admin, then you need to create another view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.