MyBB Community Forums

Full Version: edit core php file during plugin activate/deactivate
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
suggestions as the the best method for adding code to a core admin php file during activation and removing it during deactivation?

I need to add to some objects to two forms on the banning page. I've already got the code built, just need to programatically locate the point to insert the php code and add it, then remove it later.

just looking for options. are there any functions built into mybb that I can utilize or do i need to stick to php directly.
My Google SEO plugin requires a modification of a core PHP file as well, but rather than doing this automatically, I chose to only list the changes and ship a patch file as well as ready to use modified versions for MyBB 1.4.4 and 1.4.5 with my plugin.

If I were to do it programatically, all I'd do is hope that the host is installed on has the patch utils installed (unix command) and let patch do this work for me - but even that's more dangerous than I care for. Meddling with core PHP files can break a lot of things, it's better to leave this responsibility with the user.

Use hooks whereever you can. Core modifications are a last resort only.
I know core file edits are a last resort, but there are no hooks that would allow me to put the additional form elements since the admin area does not use template variables that I could edit.

I think that your suggestion to supply a modified file or manually patch instructions is the better solution, its just not the coolest implementation method.
It may be possible to hook within one of the classes. Eg, check /admin/inc/class_form.php and search for hooks there.