Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
461 views
in Q2A Core by
I'm trying to make a new page for my site, and I would like to have the users that are registered with Q2A be able to access and do some stuff with the page. How do allow only registered Q2A users do certain functions with my page?

Is there a function that I should look into?

Thanks
Q2A version: Most recent

1 Answer

+2 votes
by
edited by

Assuming you mean a page outside of your Q2A site, then you can do this by first including some Q2A files

require_once $_SERVER['DOCUMENT_ROOT'] . '/qa/qa-include/qa-base.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/qa/qa-include/qa-app-users.php';
 
Then there are a few functions you can use. To check for specific users, you can do:
 
if (qa_get_logged_in_userid() === '1') {
// userid #1 is logged in (most likely your admin account)
}
 
To check for a type of user you can do:
 
if (qa_get_logged_in_level() >= QA_USER_LEVEL_MODERATOR) {
// user is at least moderator level
}
 
You can check retain flags like this:
 
if (qa_get_logged_in_flags() & QA_USER_FLAGS_EMAIL_CONFIRMED) {
// user has email confirmed; note the single & here
}
by
Is there a list of functions somewhere on this site that I can see what conditions I can apply, to check for certain users?

Appreciate your help!
...