General developer forum

 
 
Greg watching STS 132 takeoff!
Re: Question on insert_record() function
 
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.

 
Average of ratings: -
Picture of Tim Redman
Re: Question on insert_record() function
 
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! 
 
Average of ratings: -
Greg watching STS 132 takeoff!
Re: Question on insert_record() function
 
From one newbie to another wink Happy to help!  
 
Average of ratings: -
Picture of John Rickard
Re: Question on insert_record() function
 

Fantastic page of vars

Thanks

 
Average of ratings: -
Picture of David Mudrák
Re: Question on insert_record() function
Group DevelopersGroup Documentation writersGroup Moodle HQGroup Particularly helpful MoodlersGroup 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)
Picture of lunar cry
Re: Question on insert_record() function
 
i cant download your moodlevars.php sad
 
Average of ratings: -