Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
1.5k views
in Q2A Core by

I was searching a lot on this. Found:

Post 1. global $qa_login_userid; -> not working

Post 2. global $qa_login_userid; -> not working

Post 3. $qa_cached_logged_in_user -> not working

Is there no way to detect if a user is logged in (custom theme)?

by
from qa_page.php line 692:

if (qa_is_logged_in()) {
 // a user is logged in
} else {
 // no user is logged in
}

2 Answers

+1 vote
by
selected by
 
Best answer

The most correct way is to call qa_get_logged_in_userid(...) and check if the response is null or not.

by
Thanks gidgreen,

Now I'm using:

$userid=qa_get_logged_in_userid();
if(empty($userid)) {
  // ...
}

seems to work :)
0 votes
by
You should check whether $this->content['loggedin'] is empty or not.

For example, this works:

            if(empty($this->content['loggedin']))
                $this->output('not logged in');
            else
                $this->output('logged in');
by
Thanks tonci, exactly what I needed!
...