PDA

View Full Version : Hook location for setting-changing plug-in


reismarktq2
30 Jan 2006, 23:22
Hi:

I'm in the midst of developing a custom hack for a website I run (to integrate a fantasy game they're running with various elements of vBulletin). I need to create a plug-in that will automatically change a "yesno" setting I've created in vBulletin Options after a certain time has passed.

I know how I'm going to write the plug-in; what I *don't* know is which hook location to place it in. Any suggestions?

Andreas
30 Jan 2006, 23:31
global_start

reismarktq2
02 Feb 2006, 03:51
Thanks for the help.

It turns out I was a little mistaken about how to write the plugin. It currently looks something like this:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


Here's the issue: I ran the SQL statement in phpMyAdmin to test it, and while it updates the database correctly, and I see the setting change in the control panel, I don't get the desired effect on my forum home (which is to make a couple of links disappear based on a conditional). I still need to save the settings in the control panel (even without making any changes to them!) in order for it to show up how I want it to.

I'm guessing there's something else I have to do... any ideas what it is?

Andreas
02 Feb 2006, 07:31
You have to call build_options() to rebuild the cache when you've changed a setting.
I though you just wanted to change it at runtime.

reismarktq2
09 Feb 2006, 11:46
You have to call build_options() to rebuild the cache when you've changed a setting.
I though you just wanted to change it at runtime.
I'd appreciate it if you could explain to me how to call this.

My attempts to do so resulted in my boards crashing with a function undefined error, and I had to go into phpMyAdmin and edit it out of the plugin table and the datastore manually.

Andreas
09 Feb 2006, 16:00
build_options() is defined in includes/adminfunctions.php.

Though, you really should not change settings too often.
As far as I understand the above code, it updates the setting on every pageload when the time has passed ...

reismarktq2
09 Feb 2006, 16:29
build_options() is defined in includes/adminfunctions.php.
So would I need to change the hook location to get it to run? How would I call it so that it will work from forum home?

As far as I understand the above code, it updates the setting on every pageload when the time has passed ...
It does, but I plan on adding another conditional that only updates the setting if it's currently true (which is easy enough to do). I wanted to make sure it would work without such a limit before I added it.

Andreas
09 Feb 2006, 16:43
The hook location is fine, you just need that file.

reismarktq2
09 Feb 2006, 18:38
I have that file, and it has the function in it. So why would I get this type of an error message, then?

Fatal error: Call to undefined function: build_options() in /hsphere/local/home/gabby/boards.survivoraddicts.net/global.php(351) : eval()'d code on line 134

Andreas
09 Feb 2006, 18:39
Because you don't use it :)



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

reismarktq2
09 Feb 2006, 18:41
"'I see,' said the blind man"...

So I'd just put that include at the head of the plug-in... and it works :)

Thanks!!! :D