XF 1.5 Best way to check a visitor is logged in

EasyExpat

Member
Hello,
I am using XF login to allow also member to post classifieds on external parts of the website.
I was wondering what is the best way to take into account that some users might not be unconfirmed (in that case I assume they cannot log) or banned.

Currently I am using:
PHP:
if ($visitor['user_id'])
{
}
I was wondering if I should include group_id and maybe status, such as:
PHP:
if ($visitor['user_id'] && ($visitor['user_group_id'] != 2 || $visitor['user_group_id'] != 13) && $visitor['user_state'] == "valid" &&
!$visitor['is_banned'])
{
user_state = 'valid' AND a.user_group_id <> 1 AND a.user_group_id
}
BTW what is $visitor['user_state'] == "valid"
I read some explanation here:
Among this codes, which is best:
if ($visitor['user_id'] == 0 || $visitor['user_state'] != 'email_confirm')
if ($visitor['user_id'] == 0 || $visitor['user_state'] != 'email_confirm_edit')
if ($visitor['user_id'] == 0 || $visitor['user_state'] != 'moderated')
And is !$visitor['is_banned'] necessary? I assume they cannot log?

In summary, what is the best way to allow a visitor to do something when they are legitimate, registered and have not been either discouraged or banned?

Thanks in advance for your help.
 
I have decided to implement as such:
PHP:
if (!$visitor['user_id'])
{
    //login warning
}
else if ($visitor['user_group_id'] == 13 || $visitor['is_banned']) //13 = Banned users group
{
    // banned
}
else
{
    // do stuff
}
 
Top Bottom