MyBB Community Forums

Full Version: [resolved] 1.8.3 on datahandler_post_insert_thread find PID and TID
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need the TID and PID, or a link to the new thread when the post is submitted. Is this at all possible or is there a better way of going about this?

I'm currently hooking datahandler_post_insert_thread, but all the TID's and PID's are 0 or unset (so says print_r). I'm using globals.
It depends on the exact operation that's happening. If you hit the path where an existing post is being updated (eg: going from a draft to live) you should be able to use $thread['tid'].

If it's a brand new thread, you will need to use the "datahandler_post_insert_thread_post" hook:

$plugins->add_hook('datahandler_post_insert_thread_post', 'testFunc');
function testFunc($handler)
{
    $tid = $handler->tid;
}

Unfortunately at that point, only the TID is available, not the PID - the post isn't inserted until just after that hook is ran.
(2017-11-23, 06:42 PM)Euan T Wrote: [ -> ]It depends on the exact operation that's happening. If you hit the path where an existing post is being updated (eg: going from a draft to live) you should be able to use $thread['tid'].

If it's a brand new thread, you will need to use the "datahandler_post_insert_thread_post" hook:

$plugins->add_hook('datahandler_post_insert_thread_post', 'testFunc');
function testFunc($handler)
{
    $tid = $handler->tid;
}

Unfortunately at that point, only the TID is available, not the PID - the post isn't inserted until just after that hook is ran.

Mate life saver. TYVM. <3