MyBB Community Forums

Full Version: Hook only to postbit message
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How to only hook to postbit message because when I use parse_message_end it also affects signature in the postbit and in the user profile?
<?php
// Hooks
$plugins->add_hook('parse_message_end', 'FancyPlugin2_content');

function FancyPlugin2_info(){
    return array(
        "name"            => "Your fancy plug-in",
        "description"    => "Let's check some lengths",
        "website"        => "http://mybb.com",
        "author"        => "marcus",
        "authorsite"    => "http://mybb.com",
        "guid" => "",
        "version" => "1.0",
        "compatibility" => "16*"
    );
}

function FancyPlugin2_content($content) {
	global $post;
	
	if ($post['custom_parsed']!==true) {
		$content .= ' You can do anything with the content variable, it is the message itself';
		
		// Remember to "mark it parsed"
		$post['custom_parsed'] = true;
	}
	
	return $content;
}
?>

Theoretically this should work since the message is parsed before the signature. There might be a better approach but this one also does the job.
Holy cow you have just nailed it again you are awesome I really like you man, can I borrow your brain for two days? Smile

Thanks I appreciate this big time
(2014-01-10, 03:36 PM)marcus123 Wrote: [ -> ]Holy cow you have just nailed it again you are awesome I really like you man, can I borrow your brain for two days? Smile

Thanks I appreciate this big time

You're welcome. You would need a lot of coffee to feed (/fuel) it, so it might not be worth it. Smile
I am sorry how to integrate my code into yours?

function seowords($message)
{
    global $mybb;

    $message = str_replace("SEO", "<acronym title='Search Engine Optimization'>SEO</acronym>", $message);
	$message = str_replace("test", "<acronym title='Search Engine Optimization'>seo</acronym>", $message);
  return $message;
}
<?php
// Hooks
$plugins->add_hook('parse_message_end', 'FancyPlugin2_content');

function FancyPlugin2_info(){
    return array(
        "name"            => "Your fancy plug-in",
        "description"    => "Let's check some lengths",
        "website"        => "http://mybb.com",
        "author"        => "marcus",
        "authorsite"    => "http://mybb.com",
        "guid" => "",
        "version" => "1.0",
        "compatibility" => "16*"
    );
}

function seowords($message)
{
    global $mybb;

    $message = str_replace("SEO", "<acronym title='Search Engine Optimization'>SEO</acronym>", $message);
    $message = str_replace("test", "<acronym title='Search Engine Optimization'>seo</acronym>", $message);
  return $message;
}

function FancyPlugin2_content($content) {
	global $post;
	
	if ($post['custom_parsed']!==true) {
		$content = seowords($content)';
		
		// Remember to "mark it parsed"
		$post['custom_parsed'] = true;
	}
	
	return $content;
}
?>

This should work.
No way................ you nailed it again bro. People I love this guy a lot, thanks you so much you just fix all my issues in 10 minutes now that's what I called good support Smile
(2014-01-10, 04:15 PM)marcus123 Wrote: [ -> ]No way................ you nailed it again bro. People I love this guy a lot, thanks you so much you just fix all my issues in 10 minutes now that's what I called good support Smile

Glad to help man, looks like you're up to some cool stuff on your forum, good luck with that.