How to set an exposed filter to enable current user to view nodes that he has not commented On my D7 site I am trying to create an exposed filter where current users would choose whether he wants to see all nodes, or only those that current users have not commented. Tried adding 'Comment: Comments of the node' and 'Comment: Author' relationships, 'Comment: Author uid' contextual filter. I didn't want to set a  default value because I want users to switch between all nodes and ones commented by current user. Then I added a filter criteria 'Comment: Author uid' with setting up grouped filter using [current-user:uid] token. No success yet.
As I understand it, this is impossible with just the views module by itself.

You can easily filter for nodes that the user has commented on, but filtering for nodes the user hasn't commented on is difficult for reasons I'll go into later, so you're going to have to install additional modules or write your own code.

First of all, to get the nodes the user has commented on, you've already added the correct relationships ("Comment: Comments of the node" and "Comment: Author"). However, the filter you actually need to use is "User: Current" with your author relationship selected and the option "Is the logged in user: Yes". You probably also want to use the "Distinct" option in the view's "Query Settings", otherwise you'll get duplicate rows if the user has commented multiple times on the same node.

Now, the reason you can't easily get the nodes the user hasn't commented on is because you can't just change the filter option to "Is the logged in user: No".

Why not?

Because that will go through every comment on the node, and if any of the comments are not authored by the current user, the node will be included in the results, even if it has other comments that were authored by the current user.

So, what you'd actually need to be able to do is take the list of nodes which the current user has commented on, and then exclude them from the results of the view, which simply can't be done in the standard views UI.

Without writing your own module to modify this behaviour, the best option seems to be the OtherView Filter module.

With that module, you can create a second view of nodes, which excludes the results of the first view I described above, using a "Content: Other view result" filter. For usability you'd probably want to set this up as a grouped filter to avoid having the operator and view names exposed to the user.