Time Registered on Postbit Custom
#1
Alright so a lot of forums use this function in different ways, I've had a look and it's not been shared here within the MyBB Community, I usually use it in a different way - depending on the theme you have (light/dark) you may have to make some changes. Overall with the text and color you might want to make some changes. Anyways lets get right into this tutorial.

Before we begin I have attached some examples of this feature right here for you all to see what we're going to be making. A lot of forums use it any it's seen as a milestone idea across the board. Really nice, easy to add feature.
           

We're going to be making one like the last image shown on the right. So lets get right into it, you'll need PHP in Templates, the plugin can be downloaded by visiting the developers website here. Okay so once you've installed that plugin and activated it you will be ready to begin with the rest of this tutorial. We're going to add the following titles;
  • New Member (0 days to 6 months)
  • 1 Month Member (1 months to 6 months)
  • 6 Month Member (6 months to 1 year)
  • 1 Year Member (1 year to 2 years)
  • 2 Year Member (registered 2 years ago)
Home » Template Sets » template-group-name » Edit Template: postbit

Locate the following code;
{$post['groupimage']}

Now under it add the following code;
<if $post['regdate']+(60*60*24*730) <= TIME_NOW then><span class="two-years">Two Years of Service</span><elseif $post['regdate']+(60*60*24*365) <= TIME_NOW then><span class="one-year">One Year of Service</span><elseif $post['regdate']+(60*60*24*30) <= TIME_NOW then><span class="one-month">One Month of Service</span><elseif $post['regdate']+(60*60*24*180) <= TIME_NOW then><span class="six-months">Six Months of Service</span><elseif $post['regdate'] <= TIME_NOW then><span class="new-member-postbit">New Member!</span></if>

Save this template and now head over to the global.css and at the bottom add;
/* Years of Service */

.two-years {
	color: #FFFFFF;
	text-align: center;
	font-weight: bold;
	font-size: 10px;
	background: #333;
	padding: 4px;
	border-radius: 4px;
}

.one-year {
	color: #FFFFFF;
	text-align: center;
	font-weight: bold;
	font-size: 10px;
	background: #333;
	padding: 4px;
	border-radius: 4px;
}

.one-month {
	color: #FFFFFF;
	text-align: center;
	font-weight: bold;
	font-size: 10px;
	background: #333;
	padding: 4px;
	border-radius: 4px;
}

.six-months {
	color: #FFFFFF;
	text-align: center;
	font-weight: bold;
	font-size: 10px;
	background: #333;
	padding: 4px;
	border-radius: 4px;
}

.new-member-postbit {
	color: #FFFFFF;
	text-align: center;
	font-weight: bold;
	font-size: 10px;
	background: #333;
	padding: 4px;
	border-radius: 4px;
}
Save and it should now be formatted, if not do a hard refresh (CTRL +F5).
Check out all my submissions here - click me
MyBB support at it's finest. 
Reply
#2
Nice tutorial Nasyr, this should help a lot of admins who want such feature Smile
Reply
#3
Nice tutorial, however it says like  "One month of service" for most users, even though most of them are registered longer than one month,

And it doesn't say two years of service etc. either, but one year only.

Why not consider every month/year? Idk doesn't seem very reasonable to display 1 month even though you have 5 months already e.g.
Reply
#4
(2017-03-10, 04:13 AM)WallBB Wrote: Nice tutorial Nasyr, this should help a lot of admins who want such feature Smile

Thanks buddy a lot of people like these sorta things Smile

(2017-03-10, 02:23 PM)thelovelyone Wrote: Why not consider every month/year? Idk doesn't seem very reasonable to display 1 month even though you have 5 months already e.g.

Some communities use these as a sort of milestone mark, I made it like that for this tutorial but it could be altered.
Check out all my submissions here - click me
MyBB support at it's finest. 
Reply
#5
Very helpful tutorial, thank you for sharing!
TWISTED SISTER ROCKS!
[Image: bCRctmd.jpg]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)