Trying to assign a role when user is confirmed. On testing, user is successfully assigned to a role. When I login as that user, I could see administrator homepage.
If not wrong, I guess there is no role for frontpage assigned, in moodle.
$context = context_system::instance();
if ($DB->record_exists("user", array('id' => $USER->id, 'confirmed' => '1' ))) {
role_assign($roleid, $USER->id, $context->id);
}
Appreciate your suggestions!