PDA

View Full Version : Hide [code] content from guests


Zweeper
03-10-2020, 07:11 AM
Hey, I was using this template modification to hide content from guests:
https://vborg.vbsupport.ru/showthread.php?p=2602245


unfortunately it is suddenly not working anymore with 5.6.0 (didnt do any changes, just the update).



Can anybody help me to modify the code in a way, so that it is working again?





I was using this code before:

[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)">
<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>
</div>


The problem seems to be a trouble with the group parts. When I enter the group for guests, it shows the content to everybody (of course). If I enter the groups for registered users, admins and mods, it is hidden from everybody. :(


Would appreciate any help!




Greetings!

--------------- Added 1583869352 at 1583869352 ---------------

It only works if I add usergroup "1" to the code (guests). Then its shown to all.
Otherwise its hidden for all. Strange...

shka
03-10-2020, 08:34 PM
I dont know if it is an error or a feature. Add debugvardump (! in test environment)

<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:debugvardump $user}
<vb:if condition="is_member_of($user, 2, 3, 6)">
<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>
</div>

Test in 5.5.3:
You get the vardump of the current logged in user (and also null info of not logged in) - and only then your bbcode_code makes sense

Test in fresh 5.6.0 with first post by admin and answer by registered user
In all situations (admin logged in, reg user logged in, no one logged in) I see in first post "admin-user-object" and in second post "reg-user-object".

So error in 5.6.0 or you have to use another object.

Zweeper
03-11-2020, 04:08 AM
Many thanks for your help so far.

I am also discussing this on vbulletin.com because I couldn't solve it on my own so far.

https://forum.vbulletin.com/forum/vbulletin-5-connect/vbulletin-5-connect-questions-problems-troubleshooting/vbulletin-5-support-issues-questions/4436581-hide-code-content-from-guests

shka
03-11-2020, 05:52 PM
Versuche mal /Try


<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:data currentUser, user, fetchCurrentUserinfo}
<vb:if condition="is_member_of($currentUser, 2, 3, 6)">
<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>
</div>


Da ich auch auf vB.com mitgelesen habe und Risiko nicht einsch?tzen kann - $currentUser enth?lt die gleichen Infos wie $user (nur protected), k?nnte man ja am Ende vom Template die Variable $currentUser wieder unsetten. Das m?sste aber jemand Profunderer entscheiden.

Zweeper
03-11-2020, 06:08 PM
Hey, danke für das Update, aber da tut sich leider auch nichts. Führt zum gleichen Ergebnis dass entweder allen Usern der Code verwährt wird, oder eben allen angezeigt wird. Schade, aber trotzdem danke!