Some problems, and their solutions:
Never use the PHP input filterPHP input filter.
When you are developing code, ensure that you have proper error reporting on. This would show you that you have a problem on the
$account =
line.PHP 5.3:
E_ALL | E_STRICT
PHP 5.4:
E_ALL
.Your general problem is not in code per se, but in not understanding how to debug code. If you have devel installed, you can
dpm()
values on a line per line basis, in an attempt to nail down the problem. If you were to do that, you would quickly notice that $account does not contain the values you expect.$user>uid
is actually a mathematical operation, and will not return the users uid. What you want is$user->uid
.field_view_value()
will, as the documentation suggests, return "a renderable array", it's not going to actually give you meaningful output, and since it's an array, you can'tprint
it.
I'm guessing what you actually want is:
<?php
global $user;
$account = user_load($user->uid);
$school_cats = field_get_items('user', $account, 'field_user_school_category');
foreach ($school_cats as $school_cat) {
print $school_cat['safe_value'];
}