General developer forum

Send Email to Admin when student Login

 
Picture of hitesh prajapati
Send Email to Admin when student Login
 

I want to send an email to the creator/teacher of student when any student Login to Moodle site.
i need to do this things using theme files if possible.

Also, i want to send email to users when some other users complete the course or access the course.
Admin will select the student how wants to get this kind of email notifications.

Any suggestion will be helpful to me.
Thanks. 

 
Average of ratings: -
Picture of Darko Miletić
Re: Send Email to Admin when student Login
Core developersParticularly helpful Moodlers

There is no need to code anything. Moodle already supports this through Event monitoring.

 

 
Average of ratings: Useful (2)
Picture of hitesh prajapati
Re: Send Email to Admin when student Login
 

Hi Darko, 

Thanks for Reply and your help.

i checked with Event Monitoring to send email when user login.

But my issue is, i need to send email notification to student's manager/teacher only. according to event manager teacher need to subscribe for that RULE and teacher will receive notification for all user login, not only for their student. also there is not user related data variable to send email with user details.

Same issue with when i want to send email notification to subscribe user/student of particular organization when some other user access or complete the course.

Please help me if i can add some rules/condition when creating EVENT MONITORING RULES to send emails related to their organisation and their teachers only.




 
Average of ratings: -
Picture of Darko Miletić
Re: Send Email to Admin when student Login
Core developersParticularly helpful Moodlers

In this case you would need to add code to your theme for handling such specific case.

See https://docs.moodle.org/dev/Event_2

You will need to create event observer for core\event\user_loggedin

See this thread for one example of creating event observer

https://moodle.org/mod/forum/discuss.php?d=269191#p1163034


 
Average of ratings: Useful (1)
Picture of hitesh prajapati
Re: Send Email to Admin when student Login
 

Hi Darko,

Thanks for your Replay and Help.

can you please help me for where i can add the code in my theme folder ? like...

theme/themename/anyfiles.php ??

Any of the code example will be helpful to me related to my event handling task. 


 
Average of ratings: -