Question on insert_record() function

Re: Question on insert_record() function

by Greg Lyon -
Number of replies: 5
Tim, try $USER->id

once you've done the require_once() there are a wealth of parameters available to you in Moodle.  $USER is just one of them.  ($CFG, $COURSE would be others). 

When you're learning it's quite useful to see what is contained in some of these variables.  If you haven't done this yet try (in a php page):
I also included it as a file with pretty formatting and a couple other variables.  Really helps getting you used to moodle development.

In reply to Greg Lyon

Re: Question on insert_record() function

by Tim Redman -
Thanks Greg I'd just about managed to figure out using $USER->id was the way to do it. That file you attached is excellent, I can see that coming in really handy as I continue to get to grips with moodle development, thanks! 
In reply to Tim Redman

Re: Question on insert_record() function

by Greg Lyon -
From one newbie to another wink Happy to help!  
In reply to Greg Lyon

Re: Question on insert_record() function

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Yup, this is very common way to debug Moodle code. I often use

print_object($something); die(); // DONOTCOMMIT

So often that I have a ViM macro to produce such line. Note the comment I use there. Then I can easily check (grep) I have no forgotten trace point in the code.
Average of ratings: Useful (1)