MyBB Community Forums

Full Version: Show Last active (last logged in) in postbit
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
I've made a small plugin for this - try it if you like:

Only member of groupID 3,4,6 (supermods, admins, mods) can see the last active time.
I'm working on a better version with settings & lang support. Wink
Try this:

<a name="pid{$post['pid']}" id="pid{$post['pid']}"></a>
<div class="post classic post{$usergroup['gid']} {$unapproved_shade}" style="{$post_visibility}" id="post_{$post['pid']}">
<div class="post_author scaleimages">
	<div class="author_information">
			<strong><span class="largetext">{$post['profilelink']}</span></strong> {$post['onlinestatus']}<br />
			<span class="smalltext">
				{$post['usertitle']}<br />

					var timestamp = {$post['lastvisit']}; // replace your timestamp
					var myid = {$post['pid']};
var date = new Date(timestamp * 1000);
var formattedDate = ('0' + date.getDate()).slice(-2) + '/' + ('0' + (date.getMonth() + 1)).slice(-2) + '/' + date.getFullYear() + ' ' + ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2);


	<div class="author_statistics">
		{$post['user_details']}<br/>Last Active: <span id ="myDiv{$post['pid']}"></span><script>$("#myDiv"+myid).append(formattedDate);</script>
<div class="post_content">
	<div class="post_head">
		<span class="post_date">{$post['postdate']} <span class="post_edit" id="edited_by_{$post['pid']}">{$post['editedmsg']}</span></span>
	<div class="post_body scaleimages" id="pid_{$post['pid']}">
	<div class="post_meta" id="post_meta_{$post['pid']}">
<div class="post_controls">
	<div class="postbit_buttons author_buttons float_left">
	<div class="postbit_buttons post_management_buttons float_right">

Replaces document.write with jquery.append.

Thanks SvePu Smile A plugin is better,but I just wanted to play with the javascript Big Grin
To show it with JS is also a nice idea.

First official plugin release is now available on GitHub
Leefish, how did you get so good at this stuff?
Guys, thank you very much! You are just amazing! Thank you for your time you spent because of my issue. I would like to have these knowledge in JS and PHP as you both have! Thx!

@SvePu - just one thing, I installed and activated your plugin. Set it to enable in ACP + selected groups who can view this... anyway I cannot see it in postbit - I checked and {$post['lastactive']} is added into templates. Is there anything wrong? Moreover, would you please add a setting for time format output into your plugin? Thank you!

EDIT2: Is possible to show ONLINE when the user is active in forum instead of last active time?
Dont you already have that in your theme? The green dot for online?
I made the plugin on this way that the variable "{$post['lastactive']}" is empty while the user is online.

In next version I'll integrate a time format settings option.

Quote:Is possible to show ONLINE when the user is active in forum instead of last active time?
For this you'll need another plugin. But MyBB has already a core function "Who's browsing in this forum".
OK, so hide it when the user is online would be great. I cannot see any output from your plugin in postbit Sad even user is offline
Could you temporary allow output of plugin for all user groups please - I'll take a look on your forum.

I've tested it again and it works:
Does is_member take additional groups into account?
Pages: 1 2 3 4