On a custom content type I have created, there is a List(text) field called "Assigned to" that has a drop down selection of certain emails. (E.g [email protected], [email protected], [email protected], etc.)

I have a separate view that displays fields from that content type.

I am looking for a way to filter results where the Logged in User's email field equals what is in the "Assigned to" field.

I thought of using a Contextual Filter, but that would require the user's email to be in the URL.

Could I use php code as a way to make the default contextual filter value equal the logged in user's email?

I have tried to use the following with no success:

global $user;

Thank you.

2 Answers 2


Add your "Assigned to" field as contextual filter, and set "provide default value" to PHP code just like you were thinking, but change your php snippet to return a value instead of printing:

global $user;
return $user->mail;

It is possible to provide a default value of the currently logged in user to the contextual filter. When you're configuring your contextual filter look for "Provide default value" and "type" and you'll see some options in there, the user ID for the logged in user is directly underneath the option for getting the user through the URL. You might have to play with the settings a bit but that might give you a start.

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.