Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi
I am using drupal 7 and I have printed the user object with the follwing php code.
global $user;
print_r($user);
I am getting the result only with default field values. I have two custom fields and this is not in the result.I have added these custom fields in Home » Administration » Configuration » People » Account settings.Can anybody help me on this.
Thank you in advance
Comments
Comment #1
kunalkursija CreditAttribution: kunalkursija at Blisstering Solutions commentedHi pavimal,
Instead of using
global $user; print $user;
You will have to do something like thisNote:
By default the global user object will contain the basic information of user's login. For ex: login time, session info e.t.c.
However if you want to access complete user object information, Then you will have to load the complete user object. This will also fetch all the fields and respective data.
Comment #2
cilefen CreditAttribution: cilefen commented#1 sounds correct to me.
Comment #3
kunalkursija CreditAttribution: kunalkursija at Blisstering Solutions commented