MyBB Support

Registered time function MyBB?

Submitted by AndresXZ09, , Thread ID: 2741

Thread Closed

RE: Registered time function MyBB?

AndresXZ09
Closed Account
Level:
0
Reputation:
30
Posts:
1.22K
Likes:
140
Credits:
1.51K
OP
12-04-2015, 07:14 PM
#14
12-04-2015, 07:02 PM
AmN Wrote:
Meh, I thought you guys love Spoonfeeding.

So far with you code I did this

Code:
<?php

if(!defined("IN_MYBB")) {
die("You can not access this file directly. Please make sure IN_MYBB is defined.");
}

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


// Information about the plugin
function yos_info()
{
return array(
'name' => 'Years of Service',
'description' => 'Add years of service to users post bit.',
'website' => 'http://askamn.com',
'author' => 'AmN',
'authorsite' => 'http://askamn.com',
'version' => '1.0',
'compatibility' => '*',
'gid' => '',
);
}

// Activate or deactivate the plugin
function yos_activate() {
global $db;

$yos_group = array(
'gid' => 'NULL',
'name' => 'yosplugin',
'title' => 'Years of Service',
'description' => 'Settings for the plugin',
'disporder' => "1",
'isdefault' => "1",
);
$db->insert_query('settinggroups', $yos_group);
$gid = $db->insert_id();

// Enable
$yos_setting = array(
'sid' => 'NULL',
'name' => 'yos_enable',
'title' => 'Do you want to enable the plugin?',
'description' => 'If you set this option to yes, this plugin will be active on your forum.',
'optionscode' => 'yesno',
'value' => '1',
'disporder' => 1,
'gid' => intval($gid),
);
$db->insert_query('settings', $yos_setting);
rebuild_settings();
}

// Deactivate
function yos_deactivate()
{
global $db;
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN ('yos_enable')");
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='yosplugin'");
rebuild_settings();
}

function years_of_service(){
global $mybb;

if ($mybb->settings['yos_enable'] == 1){
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']);
}
}
}

?>

Is that ok?

Users browsing this thread: 1 Guest(s)