Parsing BB Code to HTML is often required in PHP pages in MyBB. MyBB provides various types of BB code such as [img],,[font] and a lots of BB code but what if you are using MyBB integrated with a different project and you want to use those BB codes in your applications. One of the most difficult situations when you are parsing BB code to PHP in custom pages.
I have the solution for you all, it is very simple and you just need to call the below functions in your custom PHP code and that will enable you to use BB code in your PHP pages.
I have written the PHP code which you will need to copy.
|$parser = new postParser(); </code>|
|$parser_options = array(|
|'allow_html' => 'no',|
|'allow_mycode' => 'yes',|
|'allow_smilies' => 'yes',|
|'allow_imgcode' => 'yes',|
|'filter_badwords' => 'yes',|
|'nl2br' => 'yes'|
|$message = $parser->parse_message($message, $parser_options);|
As you can see,in the first two lines we are calling the inbuilt parser present in MyBB.
After that we are setting the option present in parser function and allowing Mycode in MyBB.
Remember not to enable html in parser options as there has been some issues with MyBB using html in posts which might expose your forums to vulnerability.
Hope this helps you to parse bb code to html in custom php pages, let me know in case of any issues.