Block Dveleopment - accesing user profile info

Block Dveleopment - accesing user profile info

by Sam Leach -
Number of replies: 3

Hi,

First of all, appologise if this is in the wrong place.

I am working on a moodle block and I need to access some of the fields from the users profile, for example, firstname surname and a custom profile field.

I have been looking around the development wiki and community and the tutorials are brilliant in there but I cant find anything that seems to relate to this although I am sure it is possible.

Thanks in advance

Average of ratings: -
In reply to Sam Leach

Re: Block Dveleopment - accesing user profile info

by Sam Leach -

Just as extra development, I have found this post
http://moodle.org/mod/forum/discuss.php?d=104868

And can use $USER to get the default moodle fields but not my custom fields, and the suggested sollution on the last post doesnt work (even with the syntax errors fixed)

So now ass I need help doing is accessing the custom userprofile fields.

Thanks

In reply to Sam Leach

Re: Block Dveleopment - accesing user profile info

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

In your code, do

print_object($USER);

to see everything that is there. I think you will find that the data you want is there, you just need to work out the right way to refer to it.

In reply to Tim Hunt

Re: Block Dveleopment - accesing user profile info

by Sam Leach -

Thanks, I sorted this last night.

I was using
$USER->variablename

But neeeded to use
$USER->profile['variablename']