|
Few Questions
|
|
08-11-2008, 11:32 PM
Post: #1
|
|||
|
|||
|
Few Questions
I'm working on a plugin at the moment and it's nearly done. I've used other plugins, the MyBB Wiki, and my small PHP knowledge to guide myself through the process. I'm kind of stuck, now.
This plugin is supposed to display extra information on users' postbits. The information is stored in a template that is called through a variable on the postbit or postbit_classic template. Upon turning it on, I get this error: Quote:Warning [2] call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'global_rpgstats' was given - Line: 141 - File: inc/class_plugins.php PHP 5.2.6 (Linux)
I'm certain it has something to do with how I did the hooks. I really have no clue what hooks do, or how to use them, but this is what I have after the error handling: PHP Code: $plugins->add_hook('postbit', 'postbit_author_rpgstats'); And another thing. The find and replace functions don't seem to be working for me. Upon activation, the following functions were set to run. PHP Code: // This inserts RPG stats var into postbit tempaltes.I'm losing hair quickly. If someone could point me in the right direction, it'd be nice. Thanks. |
|||
|
08-11-2008, 11:45 PM
Post: #2
|
|||
|
|||
|
RE: Few Questions
Hi,
For your error, it means that the function global_rpgstats doesn't exist. Either you added a hook you don't use, forgot to define a function or made a typo somewhere. For your find_replace_templatesets issue, your regex is incorrect. You might want to consider using preg_quote around it, eg: PHP Code: // This inserts RPG stats var into postbit tempaltes.(might be easier if you post all the code up) Who is Yumi? It's still the KFC crazed person who can't spell names properly with annoying AlTeRnAtInG CaPiTaLs in the NaMe
|
|||
|
08-12-2008, 12:16 AM
(This post was last modified: 08-12-2008 12:16 AM by Toasty.)
Post: #3
|
|||
|
|||
|
RE: Few Questions
Hey, Zinga. I'll drop the plugin, here goes:
PHP Code: <?phpBlam. Yeah. Thanks for your find and replace help. I'll implement that as soon as I get this hook thing sorted out. As for the hook, I only use it at the top. I don't know what else it's for, I pretty much got most of this done by looking at other plugins. >XD Thanks for your help! (I am the G Ninja )
|
|||
|
08-12-2008, 02:34 AM
Post: #4
|
|||
|
|||
|
RE: Few Questions
After fixing the find_replace_templatesets function from _activate and _deactivate, do this:
replace: PHP Code: $plugins->add_hook('postbit', 'postbit_author_rpgstats'); PHP Code: $plugins->add_hook('postbit', 'rpgstats_postbit'); (08-12-2008 12:16 AM)Toasty Wrote: I am the G NinjaO_O Who is Yumi? It's still the KFC crazed person who can't spell names properly with annoying AlTeRnAtInG CaPiTaLs in the NaMe
|
|||
|
08-12-2008, 03:35 AM
Post: #5
|
|||
|
|||
|
RE: Few Questions
Awesome. Everything is working perfectly except one thing.
PHP Code: <?phpThat's the new code with all the corrections (I even found a ton inconsistencies in the variables and stuff, it wouldn't have worked anyways; they're corrected now. >XD). Everything is functioning correctly, except $rpg_details isn't displaying postbit_author_rpg like it should. I think it has something to do with this line, here: PHP Code: eval("\$rpg_details = \"".$templates->get('postbit_author_rpg')."\";");
|
|||
|
08-12-2008, 07:15 AM
Post: #6
|
|||
|
|||
|
RE: Few Questions
By default, all variables defined within a function have local scope (which means they can only be "seen" from within the function).
Before the eval line, try adding: PHP Code: global $rpg_details; Who is Yumi? It's still the KFC crazed person who can't spell names properly with annoying AlTeRnAtInG CaPiTaLs in the NaMe
|
|||
Search
Member List
Calendar
Help





)