当学生使用自助注册中的注册代码注册课程时,如何向管理员发送电子邮件通知



当学生使用自助注册课程注册课程时,我需要向管理员发送电子邮件通知。

在PayPal中,有一个名为"通知管理员此帮助"的设置选项,以向用户发送电子邮件通知,但是在"自助注册"中,我没有找到任何此类选项。

是否有一些设置要启用,或者我必须编写一些自定义代码,如果我必须编写代码来发送电子邮件通知,那么我可以在哪里编写这些代码。

请帮助我。

使用事件观察器创建一个本地插件,该插件查找事件"\core\event\course_enrolment_created"。

在处理程序函数中,检查 $event->other['enregistration'] 是否与 'self' 匹配 - 如果不是,则忽略该事件。如果匹配,则使用 email_to_user(( 函数(或者更好的是,使用消息 API(向课程中的所有相关用户发送消息。

您可以使用 cron 作业并添加一些时间间隔来检查用户是否具有自我注册。如果用户具有自行注册,则调用另一个函数来发送邮件。

function checkuser(){ 
$total_time = 0;
$start_time = microtime(true);
while($total_time < 60)//run while less than a minute
{
checkFunction(); //DoSomething;
sleep(20);   //wait amount in seconds
$total_time =  microtime(true) - $start_time ;
} 
}
function checkFunction(){
//check user self enrollment here add into some variable
// check if it is true than
if($check == true){
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "rn" .
'Reply-To: webmaster@example.com' . "rn" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
} 
}

相关内容

最新更新