ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!



[TUT] Make DVZ Shoutbox Broadcast New Threads

by YASAKA, 2019-06-24 - 12:20:30

#1
 2019-06-24, 12:20:30  Last Modified: 2019-06-24, 12:20:50 by YASAKA.
add this hook in the dvz_shoutbox.php plugin file:

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

Then added this function under the dvz_shoutbox_info() function:

Code:
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') ),
    ]);
}
[Image: yasaka.png]