1

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 user1@domain.com, user2@domain.com, user3@domain.com, 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;
echo($user->mail);

Thank you.

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;
| improve this answer | |
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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