Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
316 views
in Q2A Core by
Like: 120=> Super Administrator?

1 Answer

+1 vote
by
selected by
 
Best answer

The levels are defined as constants in qa-include/app/users.php:

define('QA_USER_LEVEL_BASIC', 0);
define('QA_USER_LEVEL_APPROVED', 10);
define('QA_USER_LEVEL_EXPERT', 20);
define('QA_USER_LEVEL_EDITOR', 50);
define('QA_USER_LEVEL_MODERATOR', 80);
define('QA_USER_LEVEL_ADMIN', 100);
define('QA_USER_LEVEL_SUPER', 120);

so you could build an associative array like this:

$user_levels = Array();
foreach (get_defined_constants() as $key => $value) {
  if (preg_match('#^QA_USER_LEVEL_#', $key) === 1) {
    $user_levels[$value] = strtolower(str_replace('QA_USER_', '', $key));
  }
}

If you want the localized names instead of the (shortened) constant names you should be able to look them up somewhat like this:

$level = strtolower(str_replace('QA_USER_', '', $key));
$user_levels[$value] = qa_lang("users/$level");

You may need to handle QA_USER_LEVEL_BASIC and QA_USER_LEVEL_APPROVED differently, though, because those levels don't appear in qa-include/lang/qa-lang-users.php.

...