3 Nisan 2017 Pazartesi

Email to user when a role is assigned

When an admin/teacher assigns a role to a user in course or category context you can send an email to the user which the role has been assigned by modifying the following moodle lib file.

/var/www/html/moodle/admin/roles/assign.php

In the file around the lines 103-111 by adding email_to_user() moodle lib function you can send the email to the user from the moodle support user. Be careful that email_to_user() function accepts from and to users as moodle user objects so you can not write simply emails and send.         

   foreach ($userstoassign as $adduser) {
                $allow = true;
 

                if ($allow) {
   
                    role_assign($roleid, $adduser->id, $context->id);


                    email_to_user($adduser, $supportuser, "Your role has been assigned in Moodle", "You have been assigned as a ".$assignableroles[$roleid]." in the ".$contextname ); 
                }
            }


After you add this the user will receive an email with subject "Your role has been assigned in Moodle" and message ie. "You have been assigned as a Course creator in the Category: Mathematics"

Hiç yorum yok:

Yorum Gönder

İzleyiciler