MyBB Community Forums

Full Version: Making Mybb Plugins
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have just started my first PHP Project making Mybb Plugins Now Im trying todo the first part which Activivating & Deactivating the plugins
Heres what I have so far








Quote:
<?php

$plugins->add_hook("HOOK NAME", "FUNCTION NAME");

// The information that shows up on the plugin manager
function pluginname_info()
{
return array(
"name" => "Plugin Name",
"description" => "Plugin Description",
"website" => "Plugin's Website",
"author" => "Your name",
"authorsite" => "Your website",
"version" => "Plugin Version",
);
}

// This function runs when the plugin is activated.
function pluginname_activate()
{

require "../inc/adminfunctions_templates.php";
global $db, $mybb;

$GROUPNAME_group = array(
"gid" => "NULL",
"name" => "GROUPNAME",
"title" => "GROUP TITLE",
"description" => "GROUP DESCRIPTION",
"disporder" => "88",
"isdefault" => "no",
);

$db->insert_query(TABLE_PREFIX."settinggroups", $GROUPNAME_group);
$gid = $db->insert_id();

$PLUGINNAME_setting_1 = array(
"sid" => "NULL",
"name" => "PLUGIN SETTING NAMEenable",
"title" => "Enable",
"description" => "Would you like to enable PLUGINNAME?",
"optionscode" => "yesno", Plugin types are "yesno"(radio button), "text"(single line), and "textarea".
"value" => "yes",
"disporder" => "1",
"gid" => intval($gid),
);

$db->insert_query(TABLE_PREFIX."settings", $PLUGINNAME_setting_1);

$PLUGINNAME _setting_2 = array(
"sid" => "NULL",
"name" => "PLUGIN SETTING NAME",
"title" => "PLUGIN TITLE",
"description" => "PLUGIN DESCRIPTION",
"optionscode" => "text",
"value" => PLUGIN VALUE",
"disporder" => "2",
"gid" => intval($gid),
);

$db->insert_query(TABLE_PREFIX."settings", $PLUGINNAME_setting_2);

}

// This function runs when the plugin is deactivated.
function pluginname_deactivate()
{

require '../inc/adminfunctions_templates.php';
global $db;

$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('$PLUGIN SETTING NAME', '$PLUGIN SETTING NAME')");Here you will replace all your PLUGIN SETTING NAMES into this array
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='GROUPNAME'"); The groupname should be the same as the one created above in the activation
}

// Functions
function FUNCTION NAME(){

}

WHAT DO I PUT IN FUNCTION NAME (){

And what else do I need todo to the Codes to get the activate/Deactivate Functions working

?>
(2011-09-07, 09:29 AM)faviouz Wrote: [ -> ]You should at least know the bare basics of PHP before you even look into creating plugins. But once you have a decent understanding of how PHP works, you can definitely start messing around with other plugins' code. That's mostly how I learned. However, there are some guides I'd recommend reading as well:

http://mybbhacks.zingaburga.com/showthread.php?tid=74
http://community.mybb.com/thread-16697.html

And for detailed information about plugins, check out the official Wiki:

http://wiki.mybb.com/index.php/Authoring_Plugins
http://wiki.mybb.com/index.php/Plugins:The_Hook_System
http://wiki.mybb.com/index.php/Database_Methods

I know some basic php such as mysql_connect (dbonfo) and echo ("Hi And echo");
Still learning more PHP And thanks for those links I will check them out
This may also help, though I'd advise gaining a better knowledge of PHP asap really. http://www.mypurebb.com/302-developing-y...bb-plugin/
I got the Activate/Deactivate functions working Big Grin

Now how do I write the features Code to link with Mybb?