The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
<vb:if condition="$bbuserinfo[userid]"> Not Working
I am trying to have my BBCODE contents not viewable unless the user is logged in. I found a hack from this forum that will allow conditionals in BBCODE. I've installed that too.
What I'm trying to do is use Code:
<vb:if condition="$bbuserinfo[userid]"> 'Something here <vb:else /> 'Something else here </vb:if> Code:
<div class="bbcode_container"> <div class="bbcode_description">{vb:rawphrase code}: <input type="button" value="Click To Select" onclick="selectAll(this); return false;"></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>> <code> <vb:if condition="$bbuserinfo[userid]"> {vb:raw code} <vb:else /> <b><font color="green">Hello Guest!</font></b> <font color="black"><p>To post questions, download files, to provide solutions to queries and <b>especially to view this code</b>, <a href="register.php"><u>register for free!</u></a></p> </vb:if> </code> </pre> </div> Code:
<div class="bbcode_container"> <div class="bbcode_description">{vb:rawphrase code}: <input type="button" value="Click To Select" onclick="selectAll(this); return false;"></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>><code>{vb:raw code}</code></pre> </div> --------------- Added [DATE]1365846255[/DATE] at [TIME]1365846255[/TIME] --------------- This isn't throwing any error. However, I am not getting the message for a guest. Instead, I am getting the actual contents of the BBCode even if a user is logged in or not Code:
<div class="bbcode_container"> <div class="bbcode_description">{vb:rawphrase code}: <input type="button" value="Click To Select" onclick="selectAll(this); return false;"></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>> <code> <vb:if condition="$bbuserinfo[userid]"> <b><font color="green">Hello Guest!</font></b> <font color="black"><p>To post questions, download files, to provide solutions to queries and <b>especially to view this code</b>, <a href="register.php"><u>register for free!</u></a></p> <vb:else /> {vb:raw code} </vb:if> </code> </pre> </div> |
#2
|
|||
|
|||
I don't know what mod you installed to allow conditions, but normally the contents of posts are cached to avoid processing them over and over every time anyone views a thread. But the result is that conditons like yours don't work correctly unless something was done to avoid caching.
|
#3
|
|||
|
|||
Thanks for your inputs. The mod that I installed is https://vborg.vbsupport.ru/showthread.php?t=149107
My objective is to mask the contents within the code wrap unless the user is logged in (not a guest). I have seen countless forums doing similar things (even this forum has something that does that). I just want to know how to do that. |
#4
|
||||
|
||||
Did you read all of the modification thread? You need to have post caching disabled, as Kevin stated.
|
#5
|
|||
|
|||
Could you please let me know how to disable caching?
|
#6
|
|||
|
|||
In the admincp setting, under Server Settings and Optimization Options, set Cached Posts Lifespan to 0.
|
#7
|
|||
|
|||
I'm reading it 00:30am so maybe I'm not reading well but I believe that you have the condition just the opposite:
Code:
<vb:if condition="!$bbuserinfo[userid]"> ............Hello Guest!........... <vb:else /> {vb:raw code} </vb:if> Instead of: Code:
$bbuserinfo[userid] Code:
$vbulletin->userinfo['userid'] Edited: In my opinion is better to use: Code:
<vb:if condition="$bbuserinfo[userid] > 0"> Code:
<vb:if condition="!$bbuserinfo[userid]"> Chris |
#8
|
|||
|
|||
!$bbuserinfo[userid] is true if the userid is 0, so you're right about it being the reverse but it can be used to do the same check.
|
#9
|
|||
|
|||
Reply removed as it will leads in an endless discussion........
Chris |
#10
|
|||
|
|||
Thanks a lot everybody. It seems to be working in my forum now. I will try out the suggestions given above too. And ChrisTERis, you were right about my wrongly sequencing the conditional statement. Other than that, I am not sure about the conversion between you and Kevin (I'm sure both of you know), but I'll go with
Code:
<vb:if condition="$bbuserinfo[userid] > 0"> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|