Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
888 views
in Q2A Core by
I've been trying to work out the code for a link to display in the footer of my site such that it brings the user to the login page only if the user is not logged in. Once he/she is logged in, that same link will logout the user instead. I have Q2A linked to my WP install, so I was thinking along the lines of the wp_loginout function, but my PHP-fu isn't quite good, so any help you guys might be able to offer me would be much appreciated.
Q2A version: 1.4.3

1 Answer

0 votes
by

There may be a more direct way, but I would use something like:

if(qa_logged_in_userid()) {

    // show log out

}

else {

    // show login

}

by
Thanks for the advice. I've got something like this:

        <? php
          if (qa_get_logged_in_userid()) {
             echo '<p>Log Out</p>';
            }
          else {
              echo '<p>Log In</p>';
          }
        ?>

Inserted into the header under "Layout". Seems however, that the escape from HTML to PHP doesn't work, and I end up with the following output verbatim:

Log Out

'; } else { print '

Log In
'; } ?>

What am I not doing right?
by
I doubt those boxes allow php code (you need to use <?php, not <? php, but it probably doesn't work anyway.  Only way to go is to use a custom layer, or edit your theme's qa-theme.php.  See:

http://www.question2answer.org/layers.php
...