mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
New function to return a partial user object with the custom profile fields
set.
This commit is contained in:
parent
d9c1a97188
commit
66643c0aa8
@ -384,4 +384,27 @@ function profile_signup_fields(&$mform) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object with the custom profile fields set for the given user
|
||||
* @param integer userid
|
||||
* @return object
|
||||
*/
|
||||
function profile_user_record($userid) {
|
||||
global $CFG;
|
||||
|
||||
$user = new object();
|
||||
|
||||
if ($fields = get_records_select('user_info_field')) {
|
||||
foreach ($fields as $field) {
|
||||
require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php');
|
||||
$newfield = 'profile_field_'.$field->datatype;
|
||||
$formfield = new $newfield($field->id, $userid);
|
||||
$user->{$field->shortname} = $formfield->data;
|
||||
}
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user