I have a Drupal 9 site with three roles: Editor, Reviewer and Author.
I use the core Article content type, with one additional field: field_reviewer
. It is an Entity Relation to the user that has been assigned the task of reviwing the Article.
Articles may be created by Editors (typically from an article submitted by an external Author), or by an Author that is already a user. Editors has full access to all Articles, and may assign a Reviewer to any Article in the system.
I want to show all roles a list that is called "MyArticles". This list should have the following filter criteria:
- Content type: Article; AND
- Have a Reviewer assigned; AND
- ( Be authored by the currently logged in user; OR
- The currently logged in user is the Reviewer. )
I've tried to create a View with these filter criteria, and have no problem creating a View that matches the two first criteria.
As for the third and fourth, I can:
- Create a View that is authored by the currently logged in user (using a relation).
- Create a View where the currently logged in user is the Reviwer (using a contextual filter).
But I am unable to make a View that combine the two. By default, it looks like a contextual filter by default uses an AND relation, so adding it excludes all nodes authored by the currently logged in user from the View.
I've tried to use the contribute module "Views Contextual Filters OR"
https://www.drupal.org/project/views_contextual_filters_or
but I can't get it to work. It may have something to do with this bug report:
https://www.drupal.org/project/views_contextual_filters_or/issues/3215441
Is generating the "MyArticles" list described above doable with Views?
If not, I am prepared to create a custom module for generating this list. I think I already know how to set up a dynamic SQL query for this in PHP, but what is the correct directory to place this PHP code. Will this be a "Controller", a "Form", a "Plugin", or something else?
PS: I know this can be resolved (sort of) by using the Workflow module, but I have other requirements (not mentioned in this question) that precludes use of the Workflow module for this, so I need to do it using Views or a custom module.