2

Can I override a core function from Moodle? I changed the core function setnew_password_and_mail() and it is working there (moodlelib.php), but I would love to have that customized on my theme so I have better control depending on what selected theme I have. The function is not even in a class so I can't override a renderer.

I tried Overriding plugin renderer moodle and that worked perfect for a function within a renderer but not one single function in a library.

Thanks :)

Community
  • 1
  • 1
Brandon
  • 135
  • 2
  • 12
  • What is it that you need to do? – Russell England Feb 12 '16 at 14:38
  • I changed the aforementioned function in the core and so far it runs ok. However, each time i pull a new Moodle version it gets rewritten, so i would love to move those functions to my theme, so they load the customised ones instead of the core ones. I am aware that `setnew_password_and_mail()` is not in a renderer so i can't extended it via a renderer. Thanks – Brandon Feb 12 '16 at 18:07
  • But what have you changed the function to do? If you need to do something extra you could use an event. – Russell England Feb 12 '16 at 18:11
  • i changed the function so it would include a HTML message, nothing fancier than that – Brandon Feb 12 '16 at 18:16
  • 1
    Instead of downvoting this guy, we should all blame Moodle for the inability to deal with overrides. Even Wordpress can do. Indeed it does pretty well. It is in fact annoying (and expensive), even with git and everything, to upgrade a core-patched moodle. – moestly Sep 29 '16 at 15:05

1 Answers1

1

The answer is no about the function I'm afraid.

But you could have a local version of the language string newusernewpasswordtext which won't be overwritten by upgrades.

Go to site admin -> language -> language customisation.

Then search for newusernewpasswordtext in component 'core - moodle.php'

Then modify and save the text.

This will be stored in moodledata/lang/xx_local/moodle.php

Russell England
  • 9,436
  • 1
  • 27
  • 41
  • well, i tried and it really didn't work. The function is dumping the text as ... well pure text, instead of being rendered as html. So now i'll try to attack the issue with a local customisation of the function. @russell-england – Brandon Feb 15 '16 at 13:57