Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
1.3k views
in Q2A Core by
How do I do it?
Q2A version: 1.5.2

2 Answers

+3 votes
by
I achieved it by defining the following function in qa-base.php:

function qa_admin_gatekeeper(){
    $user_id =    qa_get_logged_in_userid();
    $user_level = qa_get_logged_in_level();
    if( (!$user_id) || (($user_level != QA_USER_LEVEL_EXPERT) &&
                ($user_level != QA_USER_LEVEL_EDITOR) &&
                ($user_level != QA_USER_LEVEL_MODERATOR) &&
                ($user_level != QA_USER_LEVEL_ADMIN)&&
                ($user_level != QA_USER_LEVEL_SUPER))){
                // don't allow access to this page to non-admin users
                header('Location: ../');
                exit;    
    }
    
}

 

Then go to: qa-page-users.php,  find this code:

require_once QA_INCLUDE_DIR.'qa-db-users.php';
require_once QA_INCLUDE_DIR.'qa-db-selects.php';
require_once QA_INCLUDE_DIR.'qa-app-format.php';

and call the function, qa_admin_gatekeeper(); immediately after it.
by
I vote for this change to get into next version.
by
Count me in. Good direction
by
thanks for answer!
by
worked perfectly, hope this gets included in the future versions.
+1 vote
by

You can redirect with header location to the home page or whenever you want. However I am not sure either it is appropriate way or not. But if it is so than you need to write just simple code with header location at the top of your theme file.

 

function doctype()
{
if(($this->template == 'users') AND (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN)){
header('Location: '.qa_path_html('qa').'');
}
 
qa_html_theme_base::doctype();
}
 
I also would like to know either this is correct way or not?
by
thanks for answer!
...