php in views contextual filter for different user roles
You could also use user_access() to see if a user has the rights do to something.
If you use some core administrative tasks, you can be sure that it will trigger only for administrators

E.g.

global $user;
if (user_access('administer site configuration')) {
  $query = $_GET['query'];
  return $query;
}
else{
  $account = user_load($user-&gt;uid);
  $myfilter = $account-&gt;field_custom['und']['0']['target_id'];
  return $myfilter;
}


Note: I used $account instead of $user_uid to store full user object; most of the contributed modules and core name the variable this way.