0

I have a View (content) created with a contextual filter. The contextual (Content:Country) filter uses PHP code to check custom fields:

global $user;
$user_uid = user_load($user->uid);
$mycountry = $user_uid->field_user_country['und']['0']['tid'];
return $mycountry;

The filter is [field_address_country] == [field_user_country] The contextual filter works fine.

However, I would like to 'disable' the filer for admin (uid=1) so that I can view all nodes regardless of the field_address_country value.

I have tried adding a condition to check for uid=1 but it doesn't work

global $user;
$user_uid = user_load($user->uid);
$mycountry = $user_uid->field_user_country['und']['0']['tid'];
if ($user_uid == '1') {return 'all';}
else {return $mycountry;};

Is there a method for returning all results (or disabling the filter) for admin user?

2
  • Strange. What does it return when you do a 'drupal_set_message()) statement on the $user_uid before returning? Commented Sep 24, 2013 at 14:33
  • What do you mean by "..a drupal_set_message()) statement on the $user_uid.." ?
    – kaipee
    Commented Sep 25, 2013 at 9:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.