MyBB Community Forums

Full Version: create a hook?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How to hook to the function that when you post a reply it shows as a post buy when you try to post a second reply in less than 24h it will update the the first post.
There actually is a built in feature that does this. Under Configuration -> Settings -> Posting -> Post Merge Time.

If you want to write your own hook, I believe you would need to use newreply_do_newreply_start and look at the verify_post_merge() function in datahandlers/post.php
(2014-07-10, 05:10 PM)jshort Wrote: [ -> ]There actually is a built in feature that does this. Under Configuration -> Settings -> Posting -> Post Merge Time.

If you want to write your own hook, I believe you would need to use newreply_do_newreply_start and look at the verify_post_merge() function in datahandlers/post.php


but this option:
Configuration -> Settings -> Posting -> Post Merge Time.
Merge with last post on that thread.

But:
(2014-07-10, 04:35 PM)marcus123 Wrote: [ -> ]it will update the the first post.
My understanding is that "first post" means the first post the user made, not necessarily the first post of the thread.
(2014-07-10, 05:41 PM)jshort Wrote: [ -> ]My understanding is that "first post" means the first post the user made, not necessarily the first post of the thread.

You right. I have a plugin that checks for duplicate post but it doesn't work with this feature. I have it hooked to:

$plugins->add_hook("datahandler_post_validate_post", "xxx");
$plugins->add_hook("datahandler_post_validate_thread", "xxx");
Anyone please?

I use:

if($post->method != "update")

To run the code when it's a new post not an update but how to also check if it's a marge post?
Ok so what you want is to check any previous replies, and merge if it was within x amount of time?

A few pre-questions
- What happens if there is a reply between your last post and this one, should they still be merged?
What are the conditions you are currently using to check for a post? (time is always a pain in the but, because PHP time uses UTC so you need to apply your offsets or use the mybb time functions and constants.

also
if($post->method != "update") 

only applies if the post is being edited, so when you edit a post that is triggered.

I think it may be worth actually using the following hook

newreply_do_newreply_start

that way before the posthandler is triggered you can hook in
if($post->method != "update")

Please allow me to correct you this will not trigger during update != "update"

As I mentioned above my plugin scans threads/replies for some info I can't discuss here, I use:
if($post->method != "update")
to check only new content not updated but this marge thing isn't triggered as new post.