PDA

View Full Version : change post upon save


yjeanrenaud
07-04-2011, 07:40 PM
Hi,

i would like to change something in messages posted.
therefore I would have written a plugin on postdats_presave hook
$checkcontent = $vbulletin->GPC['message'];
if (strpos($checkcontent, "foo"))
{
$newcontent=str_replace("foo", "bar",$checkcontent);
$vbulletin->GPC['message'] = $newcontent;
}

is this how the plugin systems work?

BirdOPrey5
07-04-2011, 08:32 PM
Assuming $vbulletin->GPC['message'] actually contains the message before it's saved then yes that is how the plugin system would work.

yjeanrenaud
07-05-2011, 04:28 AM
thanks :)
doesn't seem to work. so, how may I find out where the message is stored at the moment of this hook?
I saw other plugins https://vborg.vbsupport.ru/showthread.php?t=150761 using this, but maybe because I'm on 4.1.4 and not 3.1.6 it fails?

BirdOPrey5
07-05-2011, 11:09 AM
I will move this to the VB 4.x forum for you then. I would try $post['message'] or $newpost['message'] and see if either of those work.

The right way would be to open the php file and see what variable is actually be used around that hook. But guessing doesn't really hurt anything.

BirdOPrey5
07-26-2011, 11:44 AM
FYI the appropriate variable for this was: $this->post['pagetext']

yjeanrenaud
07-26-2011, 04:45 PM
but what's the difference to $post['message'] ?

BirdOPrey5
07-26-2011, 05:05 PM
The difference for me is that $post['message'] didn't work on my tests. If it's working for you then don't worry about it. But I can confirm $this->post['pagetext'] works on both 3.8 and 4.x.

yjeanrenaud
11-03-2012, 08:44 PM
thanks again