2020-04-18, 06:44 PM
Hi again fellow folks, this time I'm currently trying to figure out, how I can intercept a post from being made.
The thing I'm currently struggling with is getting the forum id (fid) of the thread, where the post is supposed to be made.
I am maybe a tad too tired whilst currently looking at this, so hopefully a pair of fresh eyes can give me a small hint, since I'm probably just overthinking and overdoing things right now. I am pretty grateful for any and all input, thanks.
Here is a code snip to demonstrate:
I am pretty sure I'm overthinking things, but since I'm using 4 different hooks I wanted to make sure that it would work none the less, and practically as the same. (Not differentiating between threads and posts, both will be intercepted kind of)
And once again, thanks a lot for any help.
(Also not sure which hook to use to intercept quick_reply, any advice? I would think it was inside the newreply_do_newreply_start hook)
The thing I'm currently struggling with is getting the forum id (fid) of the thread, where the post is supposed to be made.
I am maybe a tad too tired whilst currently looking at this, so hopefully a pair of fresh eyes can give me a small hint, since I'm probably just overthinking and overdoing things right now. I am pretty grateful for any and all input, thanks.
Here is a code snip to demonstrate:
<?php
// HOOKS
$plugins->add_hook( 'newreply_start', 'check_spam' );
$plugins->add_hook( 'newthread_start', 'check_spam' );
$plugins->add_hook( 'newreply_do_newreply_start', 'check_spam' );
$plugins->add_hook( 'newthread_do_newthread_start', 'check_spam' );
function check_spam() {
global $db, $mybb, $thread, $post, $forum;
// Get all Spam Limits
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."spamlimit_limit");
$spamlimit_id = 0;
while ($row = $db->fetch_array($query)) {
$fid;
if ($thread['fid']) {
$fid = $thread['fid'];
} elseif ($post['fid']) {
$fid = $post['fid'];
} elseif ($forum['fid']) {
$fid = $forum['fid'];
}
$forumArr = explode(',', $row['fids']);
if (in_array($fid, $forumArr)) {
...
}
}
...
}
I am pretty sure I'm overthinking things, but since I'm using 4 different hooks I wanted to make sure that it would work none the less, and practically as the same. (Not differentiating between threads and posts, both will be intercepted kind of)
And once again, thanks a lot for any help.
(Also not sure which hook to use to intercept quick_reply, any advice? I would think it was inside the newreply_do_newreply_start hook)