General developer forum

How to return coursemodule id?

Picture of Guilherme Radiske
Re: How to return coursemodule id?



That's how my url appears in the browser.

Tried almost every single exemple about $cmid but with no success. The only thing i can return with success on my test.php is the $COURSE->id that i've posted above.

I could post any exemple here that i've tested, but it is too much to see... tried again after your post to do this



$cmid = required_param('id', PARAM_INT);
echo $cmid;

Returns nothing.

Average of ratings: -
Re: How to return coursemodule id?
Core developersParticularly helpful MoodlersPlugin developers

When you write:


Is the main 'config.php' file in the same folder as your PHP script, or do you actually mean to write:


(as per existing examples in Moodle core).

You should also make sure you have debugging set to 'developer', if you haven't already done so (although, that won't help in this case, as you have to load the 'config.php' file correctly, before the debugging settings are initialised).

Average of ratings: -