Announcement

Collapse
No announcement yet.

Hide bb_codes for unregistered users vb 5.2 and 5.3.3

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hide bb_codes for unregistered users vb 5.2 and 5.3.3

    First of all, I apologize for my english because I use google translate.I found a solution for BBcodes to be invisible to the unregistered.It is tested both in VB 5.2 and 5.3.3.
    Admincp ยป Languages & Phrases ยป Phrase Manager ยป Add New Phrase
    Phrase Type : GLOBAL
    Product : vBulletin
    Varname : hide_code
    Text : Please Login or <a href="register.php">Register</a> to see codes
    Go to your Admincp ยป Styles & Templates ยป Style Manager ยป Your Style ยป BB Code Layout Templates

    Open bbcode_code will see this code:
    Code:
    <vb:if condition="$vboptions['codemaxlines']">
        {vb:set verticalPadding, 12}
        {vb:set horizScrollbarAllowance, 20}
        {vb:set blockCssHeight, {vb:math {vb:raw blockheight} * {vb:stylevar bbcode_code_line_height} + {vb:raw verticalPadding} + {vb:raw horizScrollbarAllowance}}}
    </vb:if>
    <div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase code}:</div>
        <pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:{vb:raw blockCssHeight};"</vb:if>>{vb:raw code}</pre>
    </div>
    Substitute for this one. Always remember that the id of users will be the ones of your forum. (Usually unregistered ID: 1) (For other users you choose who has permission)

    Code:
    <vb:if condition="$vboptions['codemaxlines']">
        {vb:set verticalPadding, 12}
        {vb:set horizScrollbarAllowance, 20}
        {vb:set blockCssHeight, {vb:math {vb:raw blockheight} * {vb:stylevar bbcode_code_line_height} + {vb:raw verticalPadding} + {vb:raw horizScrollbarAllowance}}}
    </vb:if>
    <div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase code}:</div>
    <vb:if condition="is_member_of($user, 2, 3, 6, 29, 31)">
        <pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:{vb:raw blockCssHeight};"</vb:if>>{vb:raw code}</pre>
    </vb:if>
        <vb:if condition="is_member_of($user, 1)">{vb:rawphrase hide_code}
    </vb:if>
    </div>

    The same code can be used for html_code and php_code. Changing of course {vb: rawphrase code} for the corresponding one in each case for html {vb: rawphrase html_code} and for php {vb: rawphrase php_code}

    Any doubts or clarifications in comments, as well as if they were useful, I did several hours to find this solution and I hope it will be useful
    A cordial greeting

    #2
    Thanks for sharing chicoynano!

    Originally posted by chicoynano View Post
    Always remember that the id of users will be the ones of your forum. (Usually unregistered ID: 1)
    I think you meant usergroup id not user id.

    If you are hiding the code from unregistered users (usergroup id 1) only and show to the rest of usergroups, then it would be easier to use and maintain this code by reversing the logic:

    Code:
    <vb:if condition="!is_member_of($user, 1)">
        <pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:{vb:raw blockCssHeight};"</vb:if>>{vb:raw code}</pre>
    <vb:else />
        {vb:rawphrase hide_code}
    </vb:if>
    instead of your suggested code:

    Code:
    <vb:if condition="is_member_of($user, 2, 3, 6, 29, 31)">
        <pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:{vb:raw blockCssHeight};"</vb:if>>{vb:raw code}</pre>
    </vb:if>
    <vb:if condition="is_member_of($user, 1)">{vb:rawphrase hide_code}
    </vb:if>
    I have a similar mod that does the same. The implementation is similar but I haven't released my version yet as I still see some bugs with it related to cache. The issue is in some intermittent occasions, it still hides the code even if user is logged in (I haven't heard any issue in a while though). Only after clearing system cache in AdminCP fixes the issue. Your code might have the same issue.
    Helpful? Donate. Thanks!
    Buy me a coffeePayPal QR Code
    Fast VPS Host for vBulletin:
    A2 Hosting & IONOS

    Comment


    • delicjous
      delicjous commented
      Editing a comment
      Right, I had that issue a few days ago here and now everything seems to be ok.

    #3
    Originally posted by glennrocksvb View Post
    I think you meant usergroup id not user id.
    So it is thanks for your clarification, possibly for the translator
    A cordial greeting

    Comment


      #4
      Originally posted by glennrocksvb View Post
      I still see some bugs with it related to cache. The issue is in some intermittent occasions, it still hides the code even if user is logged in (I haven't heard any issue in a while though). Only after clearing system cache in AdminCP fixes the issue. Your code might have the same issue.
      At the moment I did not give this decachรฉ error but I will be attentive thanks for warning
      A cordial greeting

      Comment


        #5
        Originally posted by glennrocksvb View Post
        Always remember that the id of users will be the ones of your forum. (Usually unregistered ID: 1)

        If you are kind enough to edit the user field by user group, why can not I edit it?
        A cordial greeting

        Comment


          #6
          Hello everybody,
          I'm trying to make this change, but when the message of the topic appears to me

          Please Login or Register to see codes if i click on the registered link it does not take me to the registration page but this message appears to me:
          Invalid page URL. If this is an error and the page must exist, contact your system administrator explaining how you got this message.


          Does anyone know where the error is?

          Comment

          Users Viewing This Page

          Collapse

          There is 1 user viewing this forum topic.

          • Guest Guest

          Latest Posts

          Collapse

          Working...
          X
          Searching...Please wait.
          An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

          Please push the back button and reload the previous window.'
          An unexpected error was returned: 'Your submission could not be processed because the token has expired.

          Please push the back button and reload the previous window.'
          An internal error has occurred and the module cannot be displayed.
          There are no results that meet this criteria.
          Search Result for "|||"