MyBB Community Forums

Full Version: [Error] Warning [2] call_user_func_array()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I made a test plugin and it works fine, i.e. activate add sample data to index template , and upon deactivating it also works fine, i.e. remove sample data. I am getting this error when I activate this plugin and check my index page. and got this error on index page.

Warning [2] call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'testplugin' was given - Line: 100 - File: inc/class_plugins.php PHP 5.2.17 (Linux)

Here is the my test plugin code,


<?php
if(!defined("IN_MYBB"))
{
die ("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("index_start","testplugin");

function testplugin_info()
		{
return array(
		
		"name"=> "test plugin",
		"description"=> "This is test description",
		"website"=> "www.example.com",
		"author"=> "sunjava1",
		"authorsite"=> "www.vubscs.tk",
		"version"=> "1.0",
			);
		}
		
function testplugin_activate(){

require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index", "#".preg_quote('{$forums}')."#i", '{$forums} <br> this is test '); 

}		

function testplugin_deactivate(){
  require MYBB_ROOT."/inc/adminfunctions_templates.php";
    find_replace_templatesets("index", "#".preg_quote('{$forums} <br> this is test ')."#i", '{$forums}'); 
}

		
?>
Well, you haven't created a function called testplugin...
okay, so this is the function which appears in ACP>>settings?
No, the function that defines the hook you used. e.g. in your case, it should be like this (after de-activate function);
function testplugin()
{
   global $mybb;
// something
}

Edit: Or if you don't want to use any function, just needs to use "Template edits" then remove the hook line, e.g.: $plugins->add_hook("index_start","testplugin");
Okay thanks