Skip to content
Advertisement

I want get userid value from a private object

I want to get the userid from:

["userid":"course_modinfo":private]=>
    string(1) "5"

Here value from moodle $mod in cm info variable, I have tried var_dump($mod->userid); but it returns nothing.

object(cm_info)#355 (40) {
  ["modinfo":"cm_info":private]=>
  object(course_modinfo)#339 (7) {
    ["course":"course_modinfo":private]=>
    object(stdClass)#354 (33) {
....
     ["userid":"course_modinfo":private]=>
    string(1) "5"
    ["sections":"course_modinfo":private]=>
    array(4) {
      [0]=>
      array(1) {

Advertisement

Answer

You can use the global variable:

$USER->id

Check this out How to get user id of current user in moodle?

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement