How to access Machine name fields in PHP? If I go to admin/config/people/accounts/fields I can see a lot of fields being mapped for LDAP on my server.

For example - for first name there is a machine name "field_fname".

How can I access this on my webform using PHP?

Like I want to display something like this on my webform through PHP:


  "Hello first_name last_name, how are you ?"
Here is a little code snippet that should load the value of field_fname into a variable called $first_name.

global $user;
// Load the user object
$user = user_load($user-&gt;uid); 

$first_name = $user-&gt;field_fname[LANGUAGE_NONE][0]['value'];