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:
=> https://github.com/SvePu/MyBB-Postbit-La...active.php

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:

{$ignore_bit}
<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">
	{$post['useravatar']}
	<div class="author_information">
			<strong><span class="largetext">{$post['profilelink']}</span></strong> {$post['onlinestatus']}<br />
			<span class="smalltext">
				{$post['usertitle']}<br />
				{$post['userstars']}
				{$post['groupimage']}

				<script>
					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);

				</script>

			</span>
	</div>
	<div class="author_statistics">
		{$post['user_details']}<br/>Last Active: <span id ="myDiv{$post['pid']}"></span><script>$("#myDiv"+myid).append(formattedDate);</script>
	</div>
</div>
<div class="post_content">
	<div class="post_head">
		{$post['posturl']}
		{$post['icon']}
		<span class="post_date">{$post['postdate']} <span class="post_edit" id="edited_by_{$post['pid']}">{$post['editedmsg']}</span></span>
	{$post['subject_extra']}
	</div>
	<div class="post_body scaleimages" id="pid_{$post['pid']}">
		{$post['message']}
	</div>
	{$post['attachments']}
	{$post['signature']}
	<div class="post_meta" id="post_meta_{$post['pid']}">
		{$post['iplogged']}
	</div>
</div>
<div class="post_controls">
	<div class="postbit_buttons author_buttons float_left">
		{$post['button_email']}{$post['button_pm']}{$post['button_www']}{$post['button_find']}{$post['button_rep']}
	</div>
	<div class="postbit_buttons post_management_buttons float_right">
		{$post['button_edit']}{$post['button_quickdelete']}{$post['button_quickrestore']}{$post['button_quote_fast']}{$post['button_quote']}{$post['button_multiquote']}{$post['button_report']}{$post['button_warn']}{$post['button_purgespammer']}{$post['button_reply_pm']}{$post['button_replyall_pm']}{$post['button_forward_pm']}{$post['button_delete_pm']}
	</div>
</div>
</div>

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
=> https://github.com/SvePu/MyBB-Postbit-La...s/tag/v1.0
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.


EDIT:
I've tested it again and it works:
[attachment=35470]
Does is_member take additional groups into account?
Pages: 1 2 3 4