How to get list of all users with a specific custom role in a course

Re: How to get list of all users with a specific custom role in a course

by Moumita Adak -
Number of replies: 0
Hi Ratish,
You could use
$DB->get_records_sql("SELECT u.* FROM {user} u, {role_assignments} ra, {role} r, {context} c WHERE ra.userid = u.id AND r.id = ra.roleid AND c.id = ra.contextid AND u.deleted = ? AND u.suspended = ? AND c.instanceid = ? AND r.shortname = ?", array(0, 0, courseid, "Short name of custom role"));

Thanks & Regards,
Moumita