• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Visitor Variable Returns User State "Valid" For Unregistered Users?

James

Well-known member
#1
When I dump the $visitor variable and view the site logged out, the user state is returned as valid. I was trying to stop guests and unactivated users from viewing things, with something like:
Code:
<xen:if is="!{$visitor.user_id} AND {$user.user_state} == 'valid'">
//code
</xen:if>
And I realised that the $user variable isn't available in the area I want it (returns null when I dump it).

Which brings me to this: Why is the user state for non-logged in users set to valid? Can't it be set to guest or something, or perhaps no user state at all?
 

Jake Bunce

XenForo moderator
Staff member
#2
That does seem strange for {$visitor.user_state} to be valid for guests. But this doesn't stop you from accomplishing your goal.

I was trying to stop guests and unactivated users from viewing things
Use this condition:

Code:
<xen:if is="{$visitor.user_id} AND {$visitor.user_state} == 'valid'">
	THIS WILL ONLY SHOW FOR VALID REGISTERED USERS
</xen:if>
 

James

Well-known member
#3
That does seem strange for {$visitor.user_state} to be valid for guests. But this doesn't stop you from accomplishing your goal.

Use this condition:

Code:
<xen:if is="{$visitor.user_id} AND {$visitor.user_state} == 'valid'">
THIS WILL ONLY SHOW FOR VALID REGISTERED USERS
</xen:if>
D'oh... how much of an idiot am I.

Thanks Jake, I guess it was late :confused: