MyBB Support

Registered time function MyBB?

Submitted by AndresXZ09, , Thread ID: 2741

Thread Closed
11-04-2015, 05:09 PM
#1
Does someone know about a function related to the registered time?

I want to do something similar to the years of service on LF but I don't know about what function does the work.

Hope you know and can help me.

Thanks :yus:

RE: Registered time function MyBB?

#2
11-04-2015, 05:09 PM
AndresXZ09 Wrote:
Does someone know about a function related to the registered time?

I want to do something similar to the years of service on LF but I don't know about what function does the work.

Hope you know and can help me.

Thanks :yus:

Its a custom Plugin
[Image: UeTXrZ5.png]

RE: Registered time function MyBB?

OP
#3
11-04-2015, 05:20 PM
Oxygen Wrote:
11-04-2015, 05:09 PM
AndresXZ09 Wrote:
Does someone know about a function related to the registered time?

I want to do something similar to the years of service on LF but I don't know about what function does the work.

Hope you know and can help me.

Thanks :yus:

Its a custom Plugin

I know, but maybe there is a function that does what I want :noh:

RE: Registered time function MyBB?

#4
its simple.

Years of service = time() - $member['regdate'];

then convert the timestamp to years. Smile
Do not let your difficulties fill you with anxiety, after all it is only in the darkest nights that stars shine more brightly. - Ali(a.s)

Developer( PHP, Python, C++, HTML+CSS, JS I am available for Hire. Message Me for details.

RE: Registered time function MyBB?

OP
#5
12-04-2015, 04:56 PM
AmN Wrote:
its simple.

Years of service = time() - $member['regdate'];

then convert the timestamp to years. Smile

Could you explain mean what do you mean with timestamp? I'm noob with the code :noh:

RE: Registered time function MyBB?

#6
12-04-2015, 05:04 PM
AndresXZ09 Wrote:
12-04-2015, 04:56 PM
AmN Wrote:
its simple.

Years of service = time() - $member['regdate'];

then convert the timestamp to years. Smile

Could you explain mean what do you mean with timestamp? I'm noob with the code :noh:

http://www.unixtimestamp.com/

Converting something like 1428851142 to 04/12/2015 @ 3:05pm (UTC)
[Image: UeTXrZ5.png]

RE: Registered time function MyBB?

OP
#7
So the timestamp goes here

time = (133123123) am I right?

RE: Registered time function MyBB?

#8
huh.

$plugins->add_hook( 'postbit', 'years_of_service' );

function years_of_service(&$post)
{
Code:
$yearsofservice = date( 'Y', TIME_NOW - $post['userregdate'] );
        $years = ( $yearsofservice == 1  ) ? 'year' : 'years';
        return str_replace( '<years_of_service>',' $yearsofservice . ' ' . $years . ' of service', $post['message'] );
}

and place this in your postbit template: <years_of_service> where you want that stuff to display.
Do not let your difficulties fill you with anxiety, after all it is only in the darkest nights that stars shine more brightly. - Ali(a.s)

Developer( PHP, Python, C++, HTML+CSS, JS I am available for Hire. Message Me for details.

RE: Registered time function MyBB?

OP
#9
12-04-2015, 05:58 PM
AmN Wrote:
huh.

$plugins->add_hook( 'postbit', 'years_of_service' );

function years_of_service(&$post)
{
Code:
$yearsofservice = date( 'Y', TIME_NOW - $post['userregdate'] );
        $years = ( $yearsofservice == 1  ) ? 'year' : 'years';
        return str_replace( '<years_of_service>',' $yearsofservice . ' ' . $years . ' of service', $post['message'] );
}

and place this in your postbit template: <years_of_service> where you want that stuff to display.

I wanted to learn actually :noh: but thank you anyway, I'll try to base my plugin on that but with configurable settings on the ACP Tongue

RE: Registered time function MyBB?

#10
just create a plugin file: amn.php

place my code in it.

add:

Code:
function amn_info()
{
   return array(
'name'=> 'AmN',
'description'=> 'Noh.',
'website'=> 'http://askamn.com/',
'author'=> 'AmN',
'authorsite'=> 'http://askamn.com',
'version'=> '1.0',
'compatibility'=> '14*,15*,16*,17*,18*',
'guid'=> ''
);
}
function amn_activate()
{
   //BLA
}
$plugins->add_hook( 'postbit', 'years_of_service' );

function years_of_service(&$post)
{
        $yearsofservice = date( 'Y', TIME_NOW - $post['userregdate'] );
        $years = ( $yearsofservice == 1  ) ? 'year' : 'years';
        return str_replace( '<years_of_service>',' $yearsofservice . ' ' . $years . ' of service', $post['message'] );
}
Do not let your difficulties fill you with anxiety, after all it is only in the darkest nights that stars shine more brightly. - Ali(a.s)

Developer( PHP, Python, C++, HTML+CSS, JS I am available for Hire. Message Me for details.


Users browsing this thread: 4 Guest(s)