I added an array field with three possible values to the user. It is called field_user_school_category. I am using Drupal 7.
I want to extract the field value for the current user and use it in a page in an if statement (in php text format). I just can't get the extract code to work. I can't even get the value to print - see code below. What am I doing wrong?!
The field is currently set up to accept multiple values. (I know I need to probably loop through to extract any other values later on). I have also tried using $school['und'][0]['safe_value'] instead of $school[0] amongst a myriad other things.
Any ideas or help would be very gratefully received.
Thanks Sheila
<?php
global $user;
$account = user_load($user>uid);
$school = field_get_items('user', $account, 'field_user_school_category');
$schoolcat = field_view_value('user', $account, 'field_user_school_category', $school[0]);
print $schoolcat;