MyBB Community Forums

Full Version: Board message by Musicalmidget
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Sir,
I have activated the plugin Board Message by Musicalmidget, I just want to know how we can put the username of the forum browser who had loged in to the forum? in the global message?
adding {username} will solve the prolem?

please help
Use

{$mybb->user['username']}

regards
zaher1988 Wrote:Use

{$mybb->user['username']}

regards

But I dont know where to add this code. I am giving the whole code here could u please edit that sir?
<?php
/**
 * Board Message Plugin for MyBB
 * Copyright © 2005 MyBB Mods
 * URL: http://mods.mybboard.com/
 * 
 * By: Musicalmidget
 * Website: http://www.musicalmidget.com/
 */

$plugins->add_hook('global_start', 'boardmsg');

function boardmsg_info()
{
	return array(
		'name'			=> 'Board Message',
		'description'	=> 'Allows administrators to add a global message to the forums header from the settings administration.',
		'website'		=> 'http://mods.mybboard.com/',
		'author'		=> 'Musicalmidget',
		'authorsite'	=> 'http://www.musicalmidget.com/',
		'version'		=> '1.0.1',
	);
}

function boardmsg_activate()
{
	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
	global $db;
	
	$boardmsg_group = array(
		'name'			=> 'boardmsg',
		'title'			=> 'Board Message Settings',
		'description'	=> 'Settings for the Board Message plugin.',
		'disporder'		=> 3,
		'isdefault'		=> 'no',
	);
	
	$db->insert_query(TABLE_PREFIX.'settinggroups', $boardmsg_group);
	$gid = $db->insert_id();
	
	$boardmsg_setting_1 = array(
		'name'			=> 'showboardmsg',
		'title'			=> 'Enable Board Message',
		'description'	=> 'Display the board message in the forum header?',
		'optionscode'	=> 'onoff',
		'value'			=> 'on',
		'disporder'		=> 1,
		'gid'			=> intval($gid),
	);
	
	$boardmsg_setting_2 = array(
		'name'			=> 'boardmsg',
		'title'			=> 'Board Message',
		'description'	=> 'Enter the message you would like to be displayed in the forum header when the board message is enabled.',
		'optionscode'	=> 'textarea',
		'value'			=> 'This is a global board message which administrators can modify from the \"Board Message Settings\" category of the Settings area in the Admin CP.',
		'disporder'		=> 2,
		'gid'			=> intval($gid),
	);
	
	$db->insert_query(TABLE_PREFIX.'settings', $boardmsg_setting_1);
	$db->insert_query(TABLE_PREFIX.'settings', $boardmsg_setting_2);
	
	$boardmsg_template = array(
		"title"		=> 'global_boardmsg',
		"template"	=> "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" class=\"tborder\">
<tbody>
<tr>
<td class=\"trow1\">\$boardmessage</td>
</tr>
</tbody>
</table>
<br />",
		"sid"		=> -1,
		"version"	=> 120,
		"status"	=> '',
		"dateline"	=> 1134703642,
	);
	
	$db->insert_query(TABLE_PREFIX.'templates', $boardmsg_template);
	find_replace_templatesets('header', '#<navigation>#', "{\$boardmsg}\n\t\t\t<navigation>");
}

function boardmsg_deactivate()
{
	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
	global $db;
	
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('showboardmsg', 'boardmsg')");
	$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='boardmsg'");
	$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='global_boardmsg'");
	
	find_replace_templatesets('header', '#{\$boardmsg}\n\t\t\t#', '', 0);
}

function boardmsg()
{
	global $mybb, $templates, $boardmsg;
	
	if($mybb->settings['showboardmsg'] != 'off')
	{
		$boardmessage = $mybb->settings['boardmsg'];
		eval("\$boardmsg = \"".$templates->get('global_boardmsg')."\";");
	}
}
?>
You change the message that the plugin shows from the Board Message setting at the following location:

ACP -> Settings -> Change -> Board Message Settings -> Board Message

Enter your desired message in the setting above, using {$mybb->user['username']} where you want the users username to appear in the message.