How to display the value of a custom field profile?

Re: How to display the value of a custom field profile?

by Tony Galvão -
Number of replies: 0
I did it! =)
Moodle 3

Follow code and the explanation:

//Need to database
global $DB;

//user_info_data, table with data of the fields
//userid, id of user
//fieldid, id of the field you wanna show
$field_value = $DB->get_record( 'user_info_data' , array( 'userid' => $userid, 'fieldid' => 1) );

//Shows the data of field
echo $field_value->data;
Average of ratings: Useful (1)