Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
517 views
in Q2A Core by
How can i use collors for the user ranks ?

for example : Admin - red / Mod - green ..etc

A css modification please?
Q2A version: latest

1 Answer

+1 vote
by

It is impossible to do this with CSS only. This is because the users section does not make any difference between user levels and outputs the same CSS for all of them. You will need to customize this in your theme at a PHP level and then apply the CSS according to the PHP customizations.

The not-so-efficent but short solution would be the following. Obviously, if you are using the "latest" version of Q2A you're using v1.7-beta-1. So my answer will accomodate to that one. I will also assume you're using Snow Flat theme (or, at least, any theme that is not already overriding ranking functions).

So you in your qa-theme.php file add this function:

public function ranking_label($item, $class) {
    if ($class === 'qa-top-users') {
        $useraccount=qa_db_single_select(qa_db_user_account_selectspec($item['raw']['userid'], true));
        if (isset($useraccount, $useraccount['level'])) {
            $class .= '-' . $useraccount['level'];
        }
    }
    $this->ranking_cell($item['label'], $class.'-label');
}
 
This will output the <td> for each element in the table with this class qa-top-users-X-label, where X is a number that corresponds to the following user levels:
  • 0: Basic user
  • 10: Approved
  • 20: Expert
  • 50: Editor
  • 80: Moderator
  • 100: Admin
  • 120: Super admin
So in order to style all Super admin users with a red color in their user link you should add this CSS style to the qa-styles.css file:
 
td.qa-top-users-120-label a {
    color: red;
}

 

by
I get blank page after do that modification.
---
I use :
Question2Answer version: 1.6.3
and the CleanStrap theme ,thanks .

Welcome to the Q&A site for Question2Answer.

If you have a question about Q2A, please ask here, in English.

To report a bug, please create a new issue on Github or ask a question here with the bug tag.

If you just want to try Q2A, please use the demo site.

Categories

...