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

James

Well-known member
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?
 
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>
 
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:
 
Top Bottom