Im wondering if anyone knows the code to remove the attachment tag from the post content?
The code is to be implemented into a plugin which im having issues with.
http://community.mybb.com/thread-113402.html
I need the code to completely remove the attachment tag or mycode perhaps using a wild card as the tag is in the format [attachment=12] etc.
I tried looking for a word filter plugin but as MyBB comes with one I had no such luck.
Thanks
Do something like this:
$plugins->add_hook('parse_message', 'test_parse');
function test_parse($message)
{
return preg_replace('#\[attachment=(\d+)\]#', '', $message);
}
(2012-02-15, 12:17 AM)Jammerx2 Wrote: [ -> ]Do something like this:
$plugins->add_hook('parse_message', 'test_parse');
function test_parse($message)
{
return preg_replace('#\[attachment=(\d+)\]#', '', $message);
}
Thanks, anyway to implement this into a postbit hook?
Why do you need it in a postbit hook, you can just add another hook. It could be done but it's a lot easier just to have two hooks.
In the code given the function is; function test_parse($message)
my function is; function X($post)
I dont know if you can combine or if it makes a difference
You can use $post in it.
$plugins->add_hook('parse_message', 'test_parse');
function test_parse($message)
{
global $post;
return preg_replace('#\[attachment=(\d+)\]#', '', $message);
}
Just do the same check in there as is done in the postbit hook.
Edit: Now that I looked into it, just add the line $attachcache = ''; in your postbit hook and it should accomplish what you want.
Hi sorry, that sorted it out.
Thought you ment replace the current hooks I already had xD
Thanks for your help guys.
The previous code worked, so Im not gonna go confusing myself.
Thanks again