PDA

View Full Version : Hook to use for firing plug-in in posts but not in pms or usernotes


mme42
01-26-2010, 03:56 PM
I have a simple str_replace plug to replace certain words/urls with a message in posts. The plug-in is fine. But, the problem is that it also fires in private messages and usernotes because they use the postbit_display_complete also. But, I only want to use this plug in posts.

I've tried other hook locations (from looking that hooks available in debug mode) but I can't find another one that works, and it seems like postbit_display_complete would be correct anyway. Here is the plug for reference:

$filterthese = array('word1', 'word2', 'word3', 'word4');
$replacement = 'censored';
if (!in_array($forum['forumid'], array(1,2,3,4))) $this->post['message'] = str_ireplace($filterthese, $replacement, $this->post['message']);

Is there a different hook that I could use? Or is there a different way to do this so that the plug-in only replaces text in posts and not anywhere else?

Thanks. :D

Lynne
01-26-2010, 04:31 PM
Put a condition around it to only work on the showthread page:
if (THIS_SCRIPT == 'showthread')
{
do stuff
}

mme42
01-26-2010, 05:09 PM
Thanks! :D Haha, that was a lot easier than I was making it.