Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当学生在自行注册中使用注册代码注册课程时,如何向管理员发送电子邮件通知_Php_Moodle - Fatal编程技术网

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

Php 当学生在自行注册中使用注册代码注册课程时,如何向管理员发送电子邮件通知,php,moodle,Php,Moodle,我需要发送一封电子邮件通知管理员,当一名学生注册自己的课程使用自行注册课程 在PayPal中,有一个名为Notify admin this help的设置选项,用于向用户发送电子邮件通知,但在Self-Enrollment中,我没有找到任何此类选项 是否有一些设置要启用,或者我必须编写一些自定义代码,如果我必须编写代码来发送电子邮件通知,那么我可以在哪里编写这些代码 请帮助我。您可以使用cron作业进行此操作,并添加一些时间间隔来检查用户是否有自注册。如果用户已自行注册,请调用另一个函数以发送邮

我需要发送一封电子邮件通知管理员,当一名学生注册自己的课程使用自行注册课程

在PayPal中,有一个名为Notify admin this help的设置选项,用于向用户发送电子邮件通知,但在Self-Enrollment中,我没有找到任何此类选项

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


请帮助我。

您可以使用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' . "\r\n" .
     'Reply-To: webmaster@example.com' . "\r\n" .
      'X-Mailer: PHP/' . phpversion();
     mail($to, $subject, $message, $headers);
   } 
 }
函数checkuser(){
$total_time=0;
$start_time=微时间(真);
while($total_time<60)//在不到一分钟的时间内运行
{
checkFunction();//DoSomething;
睡眠(20);//以秒为单位的等待量
$total_time=微时间(true)-$start_时间;
} 
}
函数checkFunction(){
//检查此处的用户自注册添加到某些变量中
//检查它是否比
如果($check==true){
$to$nobody@example.com';
$subject='主题';
$message='hello';
$headers='来自:webmaster@example.com“。”\r\n”。
答复:webmaster@example.com“。”\r\n”。
'X-Mailer:PHP/'.phpversion();
邮件($to、$subject、$message、$headers);
} 
}
使用查找事件“\core\event\course\u created”的创建

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