How to get user id of current user in moodle?

Re: How to get user id of current user in moodle?

by Davo Smith -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Take a look in the database as the mdl_user table - you can output any of the fields found in there, from the $USER global (plus a few extra, such as the custom profile fields).

So no, there is no such field as $USER->name, but there is $USER->username, $USER->firstname, $USER->lastname and, if it is what you are looking for, fullname($USER) (to output the configured full name of the user - defaulting to '[firstname] [lastname]' on a fresh install).


Average of ratings: Useful (1)