NeverEndingFlashStories
asked on
Is there an obvious syntax error in this short php code?
Hi,
I am using a CMS (moodle) which apparently has a built in function is_enrolled() to verify that the user is enrolled in the course. The function definition and example is here : Function definition
I am trying to use it but it keeps returning 'not enrolled' when the user is actually enrolled. Since I am not really good at php, i am trying to figure out whether i may have not written this right. The link that the user clicks returns the GET, domain.com/x.php?tomato=2& potato=2
the $context is a function that is copied straight from here
Help.
I am using a CMS (moodle) which apparently has a built in function is_enrolled() to verify that the user is enrolled in the course. The function definition and example is here : Function definition
I am trying to use it but it keeps returning 'not enrolled' when the user is actually enrolled. Since I am not really good at php, i am trying to figure out whether i may have not written this right. The link that the user clicks returns the GET, domain.com/x.php?tomato=2&
x.php
$courseid = $_GET["tomato"];
$userid = $_GET["potato"];
function isuserenrolled($courseid, $userid) {
$context = context_course::instance($courseid);
return is_enrolled($context, $userid, '', true);
}
if (isuserenrolled($courseid, $userid)) {
echo 'is enrolled';
}
else {
echo 'not enrolled';
}
the $context is a function that is copied straight from here
Help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.