MyBB Community Forums

Full Version: Forumbit hook plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I wanna display a icon in Forumbit with plugin , I have already used this declared :

global $db, $mybb

and this is the hook:

$plugins->add_hook("build_forumbits_forum", "addIcon");

and this is function :
function addIcon(&$forum)
{
    global $db, $mybb;
    $forum['lastposter'] = "blabla";
    return $forum;
}


it's work when try to display UID or change it with "$forum['lastposteruid']" but when try to change username with "$forum['lastposter']" it's not working  Dodgy
Hi,

check this post of Theme Variables
the problem
variable : $forum['lastposter'] not working
Hi,

maybe you have to remove the globalize $forum, as Omar G. said in this post.
whole Forumbit not working if i removed it .

maybe i'm wrong Big Grin but i thing there is nothing wrong with syntax !!!

because when try to display UID or change it with "$forum['lastposteruid']" it's works fine
Hi Proton, $forum['lastposter'] is set after the execution of the build_forumbits_forum hooks, so your value is overwritten.
Go to the following line:
https://github.com/mybb/mybb/blob/featur...st.php#L60

Paste right after:
echo var_dump($forum);
exit;

Whatever you do to to $forum in your addIcon() function should be visible there.

I don't understand if $forum['lastposter'] or $forum['lastposteruid'] worked for you, but if they didn't work it might be because they are defined or overwritten later in the code.
(2020-05-07, 01:41 PM)Omar G. Wrote: [ -> ]Go to the following line:
https://github.com/mybb/mybb/blob/featur...st.php#L60

Paste right after:
echo var_dump($forum);
exit;

Whatever you do to to $forum in your addIcon() function should be visible there.

I don't understand if $forum['lastposter'] or $forum['lastposteruid'] worked for you, but if they didn't work it might be because they are defined or overwritten later in the code.

I added it :

[Image: T6sDkUO.png]

and this is the function :

[Image: CE66DVH.png]

and I got this error !!!


[Image: jvMaf5l.png]


I'm sure I made a mistake, but I don't know where  Huh
This is not an error. The code Omar provided is to print the value of the forum variable so you can check if your variable has been set.
Check my last answer:
(2020-05-07, 01:34 PM)chack1172 Wrote: [ -> ]Hi Proton, $forum['lastposter'] is set after the execution of the build_forumbits_forum hooks, so your value is overwritten.
(2020-05-07, 02:58 PM)chack1172 Wrote: [ -> ]This is not an error. The code Omar provided is to print the value of the forum variable so you can check if your variable has been set.
Check my last answer:
(2020-05-07, 01:34 PM)chack1172 Wrote: [ -> ]Hi Proton, $forum['lastposter'] is set after the execution of the build_forumbits_forum hooks, so your value is overwritten.

I got it Big Grin
I'm sorry for that and thank you @chack1172 and Omar .

it's works Big Grin
thank you again
Pages: 1 2