0

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 ?"

1

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->uid); 

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

You can reference fields in PHP like this Reference Custom Field on User Profile

I'm not sure about Webforms and PHP but you can retrieve fields with PHP fairly easily.

  • Thanks for your answer @Ash but I am not understanding from that link. Can you please help me out here? – Kedar Joshi Jan 13 '14 at 17:01
  • Sure, if you look at the answer, he/she shows how to retrieve a field's value using PHP. Then you just print $variable to get it to output. If you don't understand PHP at that level, it'll be challenging. How I learned was by copying and pasting the code, putting in my field's name, and doing some trial and error. – Ash Jan 13 '14 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.