I am trying to write an enrol plugin for moodle and therefor I need the functions of the /moodle/enrol/cohort/lib.php file.
But when I try
global $CFG;
require_once($CFG->dirroot . '../lib.php');
it gives me
Notice: Trying to get property of non-object in /var/www/html/moodle/enrol/cohort/enrol_module/result.php on line 20
line 20 is
require_once($CFG->dirroot . '../lib.php');
The Path should be correct. Can someone tell me what is responsible for this?
@Chris Lear thanks, you were right:) I included the file where $CFG is set:
require_once('../../../config.php');
the second require part was wrong, too
require_once($CFG->dirroot.'/enrol/cohort/lib.php');
global $CFG;