Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
154 views
in Q2A Core by
We have a main website that is coded using the materializecss framework and the only purpose of that part of the website is to host a bunch of information. We have a second part of the website where we're setting up Q2A to handle questions. We wish to hide some content on the main website from the public (i.e. so only registered users can see it), and we wish to restrict the ability to ask and answer questions to only registered users on the Q&A part.

ELI5 what is the best way to setup users? Assume I'm a retard, because after staring at the documentation for an hour or two, I feel like one. :)
Q2A version: latest

1 Answer

0 votes
by

It really depends on your setup on the main website. Assuming those pages are running off PHP, and you can add your own PHP code to them, the first example from the External code page in the docs should help. You just need to change the lines in the if/else to be whatever you want to show. For example:

<?php
require_once '/PATH/TO/qa-include/qa-base.php';
require_once QA_INCLUDE_DIR.'qa-app-users.php';

if (qa_get_logged_in_userid() === null) {
    echo 'You need to <a href="/link-to-your-login-page">log in</a> to view this page';
} else {
    // do whatever you want here to display the page as normal, e.g.
    incude 'documentation-page.php';
}

 

...