MyBB Community Forums

Full Version: how to pick post id on new post insert
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
topic is saying everything, i just need PID when a user submit a post.
or
can i fetch last post from the table and use this pid?
here is my plugin defination.
i am creating a log table for referral, i mean when a user submit a post then he/she got points and a log entry will added into logs table with PID of current post.

is it possible?
If I remember correctly, you can do it like this:

function new_post_handler(){
    global $pid;
    echo "the post id is",$pid;
}
(2017-04-24, 04:23 PM)Neeeeeeeeeel.- Wrote: [ -> ]If I remember correctly, you can do it like this:

function new_post_handler(){
    global $pid;
    echo "the post id is",$pid;
}

its return 0
You can try this to check the pid:

$plugins->add_hook("datahandler_post_insert_post_end", "pid_test");

function pid_test(&$datahandler)
{
    die(var_dump($datahandler->pid));
}
(2017-04-24, 04:48 PM)doylecc Wrote: [ -> ]You can try this to check the pid:

$plugins->add_hook("datahandler_post_insert_post_end", "pid_test");

function pid_test(&$datahandler)
{
    die(var_dump($datahandler->pid));
}

its working... thank you so much...