I have a content type courses with course name, instructor, coordinator and ta fields. Instructor and coordinator are of type user_reference.

My data looks like below

course instructor coordinator

101 joe guo

102 joe larry

103 guo joe

My course view has filter criteria as below content access: access and Contextual filter : author ID

When Joe logs in, the display looks like





I'm trying to figure out how to display only the courses joe is an instructor for. It should not show 103.

Any ideas?

2 Answers 2


What you want is a contextual filter on your user reference field. It should be label like Content: Instructor (or whatever you named your instructor or coordinator field). For the When the filter value is not in the URL option, select Provide the default value and use the User ID from logged in user option.

  • Thanks you. This worked. How do I show all records 1/when administrator logs in and 2/user has a role 'chair'
    – sbucs
    Jul 28, 2015 at 13:00
  • Not sure. I've not had to use contextual filters for roles & role references. DA isn't a help forum, but a knowledge base. Mark this question as answered and ask that as a new question (after searching the site to see if it's been already asked).
    – Shawn Conn
    Jul 28, 2015 at 17:30

I actually found the answer to my question. I add this code php code WHEN THE FILTER VALUE IS NOT AVAILABLE -> Provide default value -> Type is PHP Code.

global $user;
if (in_array('administrator', $user->roles)) {
  return 'all';
else {
  return $user->uid;

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.