MyBB Community Forums

Full Version: Plugin for postbit not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This plugin is intended to align the $post['message'] to right.
Now doing this replaces the "postbit" templete text and adds {$rtlo} and {$rtlc}. But the postbit_rtlo and postbit_rtlc are not created, nor are they displayed on the page.

Any pointers?

$plugins->add_hook('showthread_start', 'rtl_run');
function rtl_activate()
{
	global $lang, $mybb, $db;
	require MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets('postbit', '#'.preg_quote('{$post[\'message\']}').'#', '{$rtlo}{$post[\'message\']}{$rtlc}');
	$new_template = '<div align="right">';
	$new_template1 = '</div>';
	$db->insert_query('templates', array(
		'title' => 'postbit_rtlo',
		'template' => $db->escape_string($new_template),
		'sid' => -1,
		'version' => 120
	));
	$db->insert_query('templates', array(
		'title' => 'postbit_rtlc',
		'template' => $db->escape_string($new_template1),
		'sid' => -1,
		'version' => 120
	));

}
function rtl_deactivate()
{
	require MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets("postbit", '#{\$rtlo}#', '', 0);
	find_replace_templatesets("postbit", '#{\$rtlc}#', '', 0);

	global $db;
	$db->delete_query('templates', 'title = "postbit_rtlo"');
	$db->delete_query('templates', 'title = "postbit_rtlc"');

}
function rtl_run()
{
	global $lang, $templates, $db, $rtl, $mybb;
	eval('$rtlo = "'.$templates->get('postbit_rtlo').'";');
	eval('$rtlc = "'.$templates->get('postbit_rtlc').'";');

}
I think that the hook was postbit not showthread_start
Adding the hook to "postbit" has the same results.
and $post['rtlc'] instead of $rtlc and $post['rtlo'] instead of $rtlo
does that work?
Nope, still left(default) aligned.
I have also come across similar problem and not able to figure out what could be problem Sad

has anyone come across such problem and found a solution? I'm sure I am missing something in code but not able to figure out what!!
try globalizing $rtlo and $rtlco and make sure the hook is postbit not showthread_start
This is so old.
Hi, finally got it solved... I missed using $post as referance parameter for postbit hook Smile