Override core functionality

Override core functionality

by bala chandra -
Number of replies: 1

Hi there,

Is there a way where I could re define/declare the core modules of moodle like message_send() or email_to_user() functions without directly editing the core files. 

Purpose is that, I would like to add some extra functionalities to happen along with the actual functionality when ever these functions are called. I could edit the core function, but, during upgrade, I might have to re-edit. 

I could add custom function, but, this functions needs to be called where ever the message_send() or email_to_user() functions are called. We have them in many places this would again consume a lot of time and resource to identify the places and add this.

Any suggestion on how this can be achieved.

Thanks in advance

Average of ratings: -
In reply to bala chandra

Re: Override core functionality

by Rebecca Rumble -

It would probably need to be an output renderer override in your theme. 

I recently wrote up a post for my own reference about overriding a different core function with links to the relevant Moodle documentation that you might find useful https://www.dgmyspace.dumgal.ac.uk/eportfolio/rumbler/2021/08/14/moodle-theme-building-role-descriptor/

You'll need to figure out where the function is being defined and what the class you need to extend is called. My guess would be somewhere either in /lib or /mod although having done a quick search it might be /message/renderer.php 

I hope that at least gives some starting points. 

I know it doesn't entirely answer the question!