PDA

View Full Version : newpost_preview - editing message on this hook...


BirdOPrey5
10-03-2010, 01:47 AM
I have working code that makes a last minute change to displayed text in a post based on a custom profile field and it works great in postbit_display_complete. Today I realized though if a user "previews" a post before submitting it the last minute change doesn't happen because this event is a different hook.

I believe what I'm looking for is newpost_preview hook. Looking in the newpost_preview template the message is contained in $previewmessage as opposed to $postt['message'] like it is in the postbit hook.

So I changed the code I was using in postbit_display_complete to replace $post['message'] with $previewmessage but it isn't working. My code is something like:


if ($vbulletin->userinfo['field16'] == "No" OR $vbulletin->userinfo['styleid'] == 20 OR $show['guest'] OR preg_match('|domain1.com|', $previewmessage) OR preg_match('|domain2.com|', $previewmessage))
{
$previewmessage = str_replace('<my html code>', '<different html code>', $previewmessage);
}


Anyway the issue is the replacement is never made, the previewed post still looks exactly the same as if nothing changed.
:confused:

--------------- Added 1286123659 at 1286123659 ---------------

Update

There must have been a typo in the code, when I re-did it it worked as expected. :o