MyBB Community Forums

Full Version: Timestamp in merged posts separator
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As you know, MyBB has a post automerging feature:
Quote:Post Merge Time
With this enabled, posts posted within x minutes by the same author right after each other, will be merged. Set the time limit (in minutes) to merge posts. Set to 0 or leave blank to disable this feature. Default: 60

When the posts are merged, they are separated by
$settings['postmergesep']
which is "hr" by default. But I'd like to change this to something more informative, e.g.:
----- Added on HH:MM

Does anyone know how to do this?
AdminCP -> Configuration -> Posting -> Merge Separator

Change it from
[hr]
to whatever you like. Smile
And how can I add a timestamp there? As far as I understand, PHP code here will not be executed...
For what you want to do, you can grab the edited time variable (usually on tcat on default theme layouts) and show it by editing templates.
This won't work if >1 merge. Basically, I need to "hook" into post merge process (file inc/datahandlers/post.php, between line 794, after forum decides to merge posts, and 802, where the DB is updated). I'll probably have to add a hook there myself, since I can't find any good hook nearby.
(2012-11-06, 03:53 PM)iarspider Wrote: [ -> ]I'll probably have to add a hook there myself, since I can't find any good hook nearby.

That's correct but if you want a solution without hooks or code changes, there is one.

The code in question is:

$post['message'] = $double_post['message'] .= "\n".$mybb->settings['postmergesep']."\n".$post['message'];

So you can just change the postmergesep variable:

$settings['postmergesep'] = "----- Added on ".my_date(); // or whatever you like

You can do that unconditionally in any hook that's run before posting or even global_start. The operation is so inexpensive that it doesn't really matter if the variable is actually used later on or not.