how to get current post id, post time in plugin
hi friends,

task: freeze post and do not let user to delete or/and edit , if 15 minutes passes after posting.

how i can find post id , post time in my plugin hook function?

any idea or code snipet or already developed plugin????/

many thanks
With Regards and many thanks.
Which hook are you using at the minute?

If you use the postbit hook, you can just do something like this:

function my_function(&$post)
    $post['pid']; // The post's ID
    $post['dateline']; // The post's time - in UNIX timestamp format
i have worked on core/plain php and framework based like cakephp.

in that scenrio we mostly pass the post id in query string and get in php code by $_GET.

here i am geting fid, which i do not require. if i get pid, i can get uid from db.

but problem is : if i go to post view page, mean i click on post name/description in thread. i go to post view page: link on my local pc is : http://localhost/mybb/thread-8.html

and in my plugin i am targetting the function : showthread_start like

$plugins->add_hook("showthread_start", "mb_hidelinks");

and in my this fucntion i need current post id.

function mb_hidelinks(){
$current_post_id = pid ? ;

any more guide line
acutaly i am making a freeze plugin, i need the pid when a user is viewing the post.
With Regards and many thanks.
Ah, for what you're trying to do, you'd have to ensure the URL included the PID. You could then use $mybb->input['pid'] to access the PID parameter of the URL. There's no other way to access the PID from the showthread_start hook that I know of.

I would advise using the postbit hook though - it would make your life a LOT easier.

Also, don't use $_GET or $_POST with MyBB - you're advised to use $mybb->input['x'] instead as it does some basic sanitisation for you.
is there any documentation defining all functions and their purpose and usage?

i am not sure what does postbit do.

i am not posting some thing on post view page. i am just reading the post/thread.

e.g, you are on thread listing page. when you click on one post, it goes to post view page, nothing posted there? am i right? or on click they are posting the post id?

any help, any one from mybb technical support?
dudes please provide a comprehensive guide, like and
And finally i solved it from my self. what i needed is here :

global $thread; # all the details of current thread.

$thread_owner_id = $thread['uid'];
$post_created_date = $thread['dateline'];

isnt it???????????

With Regards and many thanks.
That'll give you the UID of the first poster and the date of the first post, yes (so long as that's what you're looking for? I was under the impression you wanted it for every post in a thread).

As for documentation on the hooks, take a look here:
i have to take the thread owner, obviously owner is posting the first post.

mybb architecture is : if you are creating thread or posting first thread under a thread, you are owner. mybb makes entry in two table: posts and threads.

what i wanted?

i want that if owner of the post is logged in, show edit link till 15 minutes of thread post time. else do not show post edit buttons/links.

how to hide the edit, delete buttons block. i dont know
With Regards and many thanks.

Forum Jump:

Users browsing this thread: 1 Guest(s)