Permalink
Browse files

New function to return a partial user object with the custom profile …

…fields

set.
  • Loading branch information...
1 parent d9c1a97 commit 66643c0aa8d465418ec7433c70e30a5f5ed0ac48 ikawhero committed Oct 8, 2007
Showing with 23 additions and 0 deletions.
  1. +23 −0 user/profile/lib.php
View
@@ -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;
+}
+
+
?>

0 comments on commit 66643c0

Please sign in to comment.