How to get user id of current user in moodle?

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

by Richard Oelmann -
Number of replies: 0
Picture of Core developers Picture of Plugin developers Picture of Testers

If the user is logged on then $USER->id should work - but if you are writing your own code, you may have to declare the $USER variable as a global in your code.