MyBB Community Forums
Add message to users with X time registered - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Development (https://community.mybb.com/forum-68.html)
+---- Thread: Add message to users with X time registered (/thread-169691.html)



Add message to users with X time registered - Lektz - 2015-04-14

Hello

I'm looking for a way to display X text on users postbit after a year has passed since his registration, two years and so on.

A guy on another forum told me about the timestamp but I don't know how to use it properly.

I though on do something like if ($mybb->user['regdate'] => the date, timestamp or I don't know ) { echo "The message"; }

What do you guys think so far, how could it be done?


RE: Add message to users with X time registered - Rakes - 2015-04-20

$plugin->add_hook('postbit', 'x_run');


function x_run(&$post) {
      if($post['regdate'] > strtotime('-2 years'))  // Make a static int afterwards
                $post['the_display_bit'] = 'omg 2 years';
}

Then add {$post['the_display_bit']} to the postbit template.


RE: Add message to users with X time registered - Sazze - 2015-04-24

(2015-04-20, 12:17 AM)Rakes Wrote:
$plugin->add_hook('postbit', 'x_run');


function x_run(&$post) {
      if($post['regdate'] > strtotime('-2 years'))  // Make a static int afterwards
                $post['the_display_bit'] = 'omg 2 years';
}

Then add {$post['the_display_bit']} to the postbit template.

or this in the template postbit or postbit_classic

<if $post['regdate']+(60*60*24*365) <= TIME_NOW then>1 Year</if>

<if $post['regdate']+(60*60*24*730) <= TIME_NOW then>2 Years</if>

but imo a plugin is better.


RE: Add message to users with X time registered - Icon - 2015-06-12

(2015-04-24, 07:59 PM)Akay Wrote:
(2015-04-20, 12:17 AM)Rakes Wrote:
$plugin->add_hook('postbit', 'x_run');


function x_run(&$post) {
      if($post['regdate'] > strtotime('-2 years'))  // Make a static int afterwards
                $post['the_display_bit'] = 'omg 2 years';
}

Then add {$post['the_display_bit']} to the postbit template.

or this in the template postbit or postbit_classic

<if $post['regdate']+(60*60*24*365) <= TIME_NOW then>1 Year</if>

<if $post['regdate']+(60*60*24*730) <= TIME_NOW then>2 Years</if>

but imo a plugin is better.

That doesn't make it over write the other one


RE: Add message to users with X time registered - Sazze - 2015-06-12

(2015-06-12, 05:32 PM)Patchy the Pirate Wrote:
(2015-04-24, 07:59 PM)Akay Wrote:
(2015-04-20, 12:17 AM)Rakes Wrote:
$plugin->add_hook('postbit', 'x_run');


function x_run(&$post) {
      if($post['regdate'] > strtotime('-2 years'))  // Make a static int afterwards
                $post['the_display_bit'] = 'omg 2 years';
}

Then add {$post['the_display_bit']} to the postbit template.

or this in the template postbit or postbit_classic

<if $post['regdate']+(60*60*24*365) <= TIME_NOW then>1 Year</if>

<if $post['regdate']+(60*60*24*730) <= TIME_NOW then>2 Years</if>

but imo a plugin is better.

That doesn't make it over write the other one

<div align="center"><if $post['regdate']+(60*60*24*30) <= TIME_NOW then>1 month<elseif $post['regdate']+(60*60*24*60) <= TIME_NOW then>2 months</div></if>

should work


RE: Add message to users with X time registered - Lektz - 2015-06-12

You don't know how to make it over write the other one.

I use it in my forum.


RE: Add message to users with X time registered - Sazze - 2015-06-12

(2015-06-12, 07:25 PM)Lektz Wrote: You don't know how to make it over write the other one.

I use it in my forum.

Just use elseif statement. :fp:


RE: Add message to users with X time registered - Lektz - 2015-06-13

(2015-06-12, 08:33 PM)Akay Wrote:
(2015-06-12, 07:25 PM)Lektz Wrote: You don't know how to make it over write the other one.

I use it in my forum.

Just use elseif statement. :fp:

I was referring to Pirate lol


RE: Add message to users with X time registered - Sazze - 2015-06-13

(2015-06-13, 01:49 PM)Lektz Wrote:
(2015-06-12, 08:33 PM)Akay Wrote:
(2015-06-12, 07:25 PM)Lektz Wrote: You don't know how to make it over write the other one.

I use it in my forum.

Just use elseif statement. :fp:

I was referring to Pirate lol

I posted the solution, but nope, his forum is weird af since it can't handle elseif it seems like (threads went crazy n stuff) lol.