PDA

View Full Version : Getting the date/time of last post in a thread


MarkFL
03-29-2015, 03:50 PM
Hello everyone!

I am currently working on a plugin that will automatically generate a report if a new user, that is one with less than 10 posts, posts a reply to a thread whose last post was made a significant time ago.

What I have done so far is check the difference between the ids of the last post and the post that has just been submitted, using the expression:

$post['postid'] - $threadinfo['lastpostid']

This works, and I am able then to auto-create a thread in our "Reported Posts" forum.

However, this is not completely satisfactory as it is based on forum posting activity (which could change of course) and not on time (the passage of which is constant), but I have thus far not been able to get the date/time information of the last post. For example, the expression:

$threadinfo['lastposttime']

returns a blank. Does anyone know which subscript contains the information regarding the last post's dateline, or otherwise how to obtain this information?

kh99
03-30-2015, 11:00 AM
I think you might want $threadinfo['lastpost'].

MarkFL
03-30-2015, 12:24 PM
I think you might want $threadinfo['lastpost'].

I just gave that a try, but it returns a blank as well. :(

Dave
03-30-2015, 12:31 PM
Where do you hook into to get the $threadinfo['lastpost'] variable? It should contain the timestamp of the last post.

MarkFL
03-30-2015, 12:39 PM
The hook location of the plugin is "newpost_complete." I am relatively new to writing plugins, so I'm not sure if this is what you mean. :D

Dave
03-30-2015, 12:59 PM
That's weird, $threadinfo['lastpost'] should have a value at that hook location.
Put the following in the hook and see what's displayed on the screen, maybe also post some more code of the plugin.


print_r($threadinfo);
exit;

MarkFL
03-30-2015, 01:18 PM
That's weird, $threadinfo['lastpost'] should have a value at that hook location.
Put the following in the hook and see what's displayed on the screen, maybe also post some more code of the plugin.


print_r($threadinfo);
exit;


Thanks...okay here's what I got using your code:

Array ( [isdeleted] => 0 [issubscribed] => 0 [emailupdate] => [folderid] => [threadread] => 1427725346 [forumread] => 1427725347 [description] => Hey everyone! [threadid] => 124 [title] => Hello again!! [prefixid] => [firstpostid] => 410 [lastpostid] => 802 [lastpost] => 1427725346 [forumid] => 10 [pollid] => 0 [open] => 1 [replycount] => 3 [postercount] => 2 [hiddencount] => 0 [deletedcount] => 0 [postusername] => regular dumb dude [postuserid] => 4 [lastposter] => MarkFL [lastposterid] => 1 [dateline] => 1420537306 [views] => 72 [iconid] => 0 [notes] => [visible] => 1 [sticky] => 0 [votenum] => 0 [votetotal] => 0 [attach] => 0 [similar] => [taglist] => [keywords] => [dbtech_thanks_disabledbuttons] => 0 [dbtech_thanks_requiredbuttons_content] => 0 [dbtech_thanks_requiredbuttons_attach] => 0 )

I see that $threadinfo['lastpost'] does in fact have a value there...perhaps I am not using PHP correctly to display it.

Okay, I just discovered I had a typo in my plugin when I attempted to use $threadinfo['lastpost'] before and it works beautifully now. My apologies for the added confusion. :o

I am very grateful for the help, and once I have this plugin working correctly I will post the complete code. I have one other issue I want to iron out with this, and that is to set the reported post into the moderation queue, but I will create a separate thread for that once I have the timestamp worked out. :D