MyBB Community Forums

Full Version: Make DVZ Shoutbox broadcast the new threads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I want DVZ Shoutbox to say "X has created a new thread titled X in the category X" - I've seen a lot of forums that use DVZ Shoutbox done that but I can't find such option in the DVZ Shoutbox settings :/

Like that: [Image: Capture.jpg]

Thanks!


I did it.

How?

I added this hook in the dvz_shoutbox.php plugin file:

$plugins->add_hook('newthread_do_newthread_end', "NEWTHREAD_BROADCAST");

Then I added this function under the dvz_shoutbox_info() function:

function NEWTHREAD_BROADCAST() {
	global $db, $mybb, $tid;
	$GET_THREAD_INFO = $db->query("SELECT * FROM ".TABLE_PREFIX."threads WHERE tid='$tid'");
	$thread_row = $GET_THREAD_INFO->fetch_assoc();
	$GET_CATEGORY_INFO = $db->query("SELECT * FROM ".TABLE_PREFIX."forums WHERE fid='".$thread_row['fid']."'");
	$category_row = $GET_CATEGORY_INFO->fetch_assoc();
	 $db->insert_query('dvz_shoutbox', [
        'uid'       => intval($thread_row['uid']),
        'text'      => "[b][i]New thread [url=".$mybb->settings['bburl']."/showthread.php?tid=$tid]".$thread_row['subject']."[/url] posted in [url=".$mybb->settings['bburl']."/forumdisplay.php?fid=".$thread_row['fid']."]".$category_row['name']."[/url][/i][/b]",
        'date'      => TIME_NOW,
        'ipaddress' => $db->escape_binary( my_inet_pton('127.0.0.1') ),
    ]);
}
Thanks to this awesome plugins tutorial: https://community.mybb.com/thread-123172.html and the plugins hook documentation ( https://docs.mybb.com/1.8/development/plugins/hooks/ )
https://github.com/Qwizi/DVZ-ShoutBox-Bot

You can use this plugin too.
Great, good job
how to make it BROADCAST new granted awards & membership !
not working Sad
(2021-02-09, 10:29 AM)Regorce Wrote: [ -> ]not working Sad

Try this

Replace this line
	$thread_row = $GET_THREAD_INFO->fetch_assoc();


With this
	$thread_row = $db->fetch_array($GET_THREAD_INFO);

Then replace
$category_row = $GET_CATEGORY_INFO->fetch_assoc();

With this
$category_row = $db->fetch_array($GET_CATEGORY_INFO);
(2021-02-09, 01:20 PM)dragonexpert Wrote: [ -> ]
(2021-02-09, 10:29 AM)Regorce Wrote: [ -> ]not working Sad

Try this

Replace this line
	$thread_row = $GET_THREAD_INFO->fetch_assoc();


With this
	$thread_row = $db->fetch_array($GET_THREAD_INFO);

Then replace
$category_row = $GET_CATEGORY_INFO->fetch_assoc();

With this
$category_row = $db->fetch_array($GET_CATEGORY_INFO);
Hey sir first thank you do much for helping me again, and the issue was i put the code directly after this line dvz_shoutbox_info()  and not the whole function, so after many fails i just realized i had to put it after the whole function, anyway thank you so much for your help <3