Kelvin Yong |
06-15-2015 09:00 PM |
Hide [code],[html],[php] BBCode from Unregistered/Unverified
1 Attachment(s)
I have searched for such mod on the forums and couldn't find a fully functional one - either due to post cache issue or etc.
I have created something similar and fully functional without any cache issue based on kh99's (moderator at vb.org) idea. This is my first release on this forum so hope that you guys don't go hard on me.
Features: - Hide [code], [html] and [php] from Unregistered/Unverified account.
- Works on all normal postbit, printable view & mobile style.
Installation:
1) Go to AdminCP -> Styles & Templates -> Style Manager -> *PRIMARY PARENT STYLE* -> Expand Template
2) Select BB Code Layout Templates -> Replace bbcode_code with the following:
HTML Code:
<!-- START PRIVATE BBCODE -->
<div class="bbcode_container">
<div class="bbcode_description">{vb:rawphrase code}:</div>
<pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:<vb:if condition="$blockheight<$vboptions['codemaxlines']">{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}*2}<vb:else />{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>>{vb:raw code}</pre>
</div>
<!-- END PRIVATE BBCODE -->
3) Replace bbcode_code_printable with the following:
HTML Code:
<!-- START PRIVATE P_BBCODE -->
<div class="bbcode_container">
<div class="bbcode_description">{vb:rawphrase code}:</div>
<hr /><code class="bbcode_code">{vb:raw code}</code><hr />
</div>
<!-- END PRIVATE P_BBCODE -->
4) Replace bbcode_html with the following:
HTML Code:
<!-- START PRIVATE BBCODE -->
<div class="bbcode_container">
<div class="bbcode_description">{vb:rawphrase html_code}:</div>
<pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:<vb:if condition="$blockheight<=$vboptions['codemaxlines']">{vb:math {vb:math {vb:raw blockheight}+2}}*{vb:stylevar mid_fontSize}}<vb:else />{vb:math {vb:math {vb:raw blockheight}+1}*{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>>{vb:raw code}</pre>
</div>
<!-- END PRIVATE BBCODE -->
5) Replace bbcode_html_printable with the following:
HTML Code:
<!-- START PRIVATE P_BBCODE -->
<div class="bbcode_container">
<div class="bbcode_description">{vb:rawphrase html_code}:</div>
<hr /><code class="bbcode_code">{vb:raw code}</code><hr />
</div>
<!-- END PRIVATE P_BBCODE -->
6) Replace bbcode_php with the following:
HTML Code:
<!-- START PRIVATE BBCODE -->
<div class="bbcode_container">
<div class="bbcode_description">{vb:rawphrase php_code}:</div>
<div class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:<vb:if condition="$blockheight<$vboptions['codemaxlines']">{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}*2}<vb:else />{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>><code>{vb:raw code}</code></div>
</div>
<!-- END PRIVATE BBCODE -->
7) Replace bbcode_php_printable with the following:
HTML Code:
<!-- START PRIVATE P_BBCODE -->
<div class="bbcode_container">
<div class="bbcode_description">{vb:rawphrase php_code}:</div>
<hr /><code class="bbcode_code">{vb:raw code}</code><hr />
</div>
<!-- END PRIVATE P_BBCODE -->
8) Select *PRIMARY MOBILE STYLE* -> Expand Template -> BB Code Layout Templates
9) Replace bbcode_code with the following:
HTML Code:
<!-- START PRIVATE M_BBCODE -->
<div class="bbcode_container">
<div class="bbcode_description">{vb:rawphrase code}: [<a href="#" class="view">{vb:rawphrase view}</a>]</div>
<pre class="bbcode_code">{vb:raw code}</pre>
</div>
<!-- END PRIVATE M_BBCODE -->
10) Replace bbcode_html with the following:
HTML Code:
<!-- START PRIVATE M_BBCODE -->
<div class="bbcode_container">
<div class="bbcode_description">{vb:rawphrase html_code}: [<a href="#" class="view">{vb:rawphrase view}</a>]</div>
<pre class="bbcode_code">{vb:raw code}</pre>
</div>
<!-- END PRIVATE M_BBCODE -->
11) Replace bbcode_php with the following:
HTML Code:
<!-- START PRIVATE M_BBCODE -->
<div class="bbcode_container">
<div class="bbcode_description">{vb:rawphrase php_code}: [<a href="#" class="view">{vb:rawphrase view}</a>]</div>
<div class="bbcode_code"><code>{vb:raw code}</code></div>
</div>
<!-- END PRIVATE M_BBCODE -->
12) Now we're done with the template modification, we'll now move on to plugin.
13) Select Plugins & Products -> Add New Plugin for the normal postbit with the following:
PHP Code:
Product: vBulletin
Hook Location: postbit_display_complete
Title: Private BBCode - Unregistered/Unverified
Plugin PHP Code:
global $vbulletin;
static $unregistered_code_replacement = '
<div class="bbcode_container">
<div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b> please <a href="register.php">register</a> or <a href="#login-box" class="login-window">login</a> to view this content.</div>
<pre class="bbcode_code">Unregistered or guests cannot view this content.</pre>
</div>';
static $unverified_code_replacement = '
<div class="bbcode_container">
<div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b> request <a href="register.php?do=requestemail">activation</a> or <a href="sendmessage.php">contact us</a></div>
<pre class="bbcode_code">Unverified account cannot view this content.</pre>
</div>';
if (is_member_of($vbulletin->userinfo, 1)) {
$post['message'] = preg_replace('#<!-- START PRIVATE BBCODE -->.*?<!-- END PRIVATE BBCODE -->#s', $unregistered_code_replacement, $post['message']);
}
if (is_member_of($vbulletin->userinfo, 3, 4)) {
$post['message'] = preg_replace('#<!-- START PRIVATE BBCODE -->.*?<!-- END PRIVATE BBCODE -->#s', $unverified_code_replacement, $post['message']);
}
14) Add New Plugin for the mobile style with the following:
PHP Code:
Product: vBulletin
Hook Location: postbit_display_complete
Title: Private BBCode - Unregistered/Unverified (M)
Plugin PHP Code:
global $vbulletin;
static $unregistered_code_replacement = '
<div class="bbcode_container">
<div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b> [<a href="#" class="view">View</a>]</div>
<pre class="bbcode_code">Unregistered or guests cannot view this content.</pre>
</div>';
static $unverified_code_replacement = '
<div class="bbcode_container">
<div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b> [<a href="#" class="view">View</a>]</div>
<pre class="bbcode_code">Unverified account cannot view this content.</pre>
</div>';
if (is_member_of($vbulletin->userinfo, 1)) {
$post['message'] = preg_replace('#<!-- START PRIVATE M_BBCODE -->.*?<!-- END PRIVATE M_BBCODE -->#s', $unregistered_code_replacement, $post['message']);
}
if (is_member_of($vbulletin->userinfo, 3, 4)) {
$post['message'] = preg_replace('#<!-- START PRIVATE M_BBCODE -->.*?<!-- END PRIVATE M_BBCODE -->#s', $unverified_code_replacement, $post['message']);
}
14) Add New Plugin for the printable view with the following:
PHP Code:
Product: vBulletin
Hook Location: printthread_post
Title: Private BBCode - Unregistered/Unverified (P)
Plugin PHP Code:
global $vbulletin;
static $unregistered_code_replacement = '
<div class="bbcode_container">
<div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b></div>
<hr /><code class="bbcode_code">Unregistered or guests cannot view this content.</code><hr />
</div>';
static $unverified_code_replacement = '
<div class="bbcode_container">
<div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b></div>
<hr /><code class="bbcode_code">Unverified account cannot view this content.</code><hr />
</div>';
if (is_member_of($vbulletin->userinfo, 1)) {
$post['message'] = preg_replace('#<!-- START PRIVATE P_BBCODE -->.*?<!-- END PRIVATE P_BBCODE -->#s', $unregistered_code_replacement, $post['message']);
}
if (is_member_of($vbulletin->userinfo, 3, 4)) {
$post['message'] = preg_replace('#<!-- START PRIVATE P_BBCODE -->.*?<!-- END PRIVATE P_BBCODE -->#s', $unverified_code_replacement, $post['message']);
}
15) DONE.
Now the [code],[html],[php] BBCode should be hidden from unregistered and unverified accounts - of course, feel free to alter the codes above to match your needs.
Have a great day.
|