MyBB-Plugins Forums

Full Version: Hooks
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I guess I am confused about hooks.... I assumed if you hooked in to someone elses code, it would run yours.

PHP Code:
//the hook in the newpoints menu

// The information that shows up on the plugin manager
function buynewpoints_info(){
    return array(
"name" => "Buy NewPoints",
"description" => "The ability to buy NewPoints with paypal.",
"website" => "",
"author" => "coreyman",
"authorsite" => "",
"version" => "0.0.1",
"guid"             => "",
"compatibility"    => "*"

// This function runs when the plugin is activated.
function buynewpoints_activate(){
//check if newpoints is installed before we do any of this.
if(! $db->table_exists("newpoints_settings")){
//tell them NewPoints is not installed
flash_message('NewPoints is not installed.''error');

"gid" => "NULL",
"name" => "MainSettings",
"title" => "Buy NewPoints",
"description" => "Main settings for Buy NewPoints.",
"disporder" => "100",
"isdefault" => "no",

$gid $db->insert_id();

$BUYNEWPOINTS_setting_1 = array(
"sid" => "NULL",
"name" => "Button_Id",
"title" => "Button Id",
"description" => "The id of your paypal buy now button.",
"optionscode" => "text",
//Plugin types are "yesno"(radio button), "text"(single line), and "textarea".
"value" => "",
"disporder" => "1",
"gid" => intval($gid),



// This function runs when the plugin is deactivated.
function buynewpoints_deactivate(){
//for some weird reason we have to include TABLE_PREFIX here and not in the insert_query
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='Button_Id'");
$db->query("DELETE FROM  ".TABLE_PREFIX."settinggroups WHERE name='MainSettings'");

//the function to add the option to buy to the menu
function add_menu(){
$menu[3] = '<a href="#">Buy NewPoints</a>';


PHP Code:
// build the menu

$menu = array();
// default menu options
$menu[0] = '<a href="'.$mybb->settings['bburl'].'/newpoints.php">'.$lang->newpoints_home.'</a>';
if (
$mybb->settings['newpoints_main_statsvisible'] == 1)
$menu[1] = '<a href="'.$mybb->settings['bburl'].'/newpoints.php?action=stats">'.$lang->newpoints_statistics.'</a>';
if (
$mybb->settings['newpoints_main_donationsenabled'] == 1)
$menu[2] = '<a href="'.$mybb->settings['bburl'].'/newpoints.php?action=donate">'.$lang->newpoints_donate.'</a>';


I want to hook in right there and add a menu option Sad
globalize $menu and add it Smile (add global $menu; before $menu[3] = '<a href="#">Buy NewPoints</a>'; )
(11-23-2009, 08:18 AM)Pirata Nervo Wrote: [ -> ]globalize $menu and add it Smile (add global $menu; before $menu[3] = '<a href="#">Buy NewPoints</a>'; )

I figured it would just plug the code in the function in and not mess with scope.
What do you mean?
Yea I don't even know what I was thinking... Tongue
If I wanted to hook some javascript into the header, how would I go about doing that?

I searched the hooks list for header and I only found admin header.

Maybe what I'm trying to do isn't even hooking but modifying a template, if so.... how do I modify a template?
You must modify the headerinclude template, take a look at a plugin which edits templates. I believe the hello world plugin does it