How to do I create a filter on my view that filters based on the value of one field being equal to the name of the currently logged in user? The field is static.
3 Answers
You can use contextual filter, as suggested by DRUPWAY in his comment.
- Add a new contextual filter
- Select the field to use
- For When the filter value is NOT in the URL, select Provide value, and then PHP code for Type
- In PHP contextual filter code, enter the following code
global $user; return $user->name;
For the user ID, it would be simpler: In step 3, you would select User ID from logged in user.
In view Relationships add "author" then in FILTER CRITERIA Add (User: Current) and select (yes) in "Is the logged in user"..
-
Hi @a.alshamiri, please try not to provide one-sentence answers. If possible provide a step-by-step guide with screenshots of each step, or of the final configuration screen. Thanks! Feb 13, 2017 at 15:29
-
In Drupal 8 you can just use the module: