Quote:
Originally Posted by Jaxel
Okay... since no one knows how to script BB code... how about something different...
How would I make a script that examines a new post and preg_matches a thread and replaces it with content? So if someone made a post and it had:
[VIDEO]536[/VIDEO] I would want it to preg_match it with:
\[(VIDEO|video)]([\d]*)\[/(VIDEO|video)] Then of course, I would run some PHP code on the preg_match[2] returned as 536.
Would this be possible?
|
I posted this in another thread a bit earlier, it should help you out
You'll require two plugins for this. I posted their source as xml just because it included everything. Just pay particular attention to the hook location and the basic functions I included.
This one will take the text to be posted, and submit it to a function so can it can be run through a preg_replace or similar function.
Code:
<plugin active="1" executionorder="5">
<title>Title Of Mod</title>
<hookname>postbit_display_complete</hookname>
<phpcode><![CDATA[global $vbulletin;
$this->post['message'] = Function_Name($this->post['message']);
]]></phpcode>
</plugin>
Another code in the global_start hook can be used to hold the source of the link replacement, modify the post and return it however you want.
Code:
<title>Plugin Title</title>
<hookname>global_start</hookname>
<phpcode><![CDATA[
function Function_Name($post) {
global $vbulletin;
//Preg_replace + other Functions
return $post;
}
]]></phpcode>