Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
622 views
in Q2A Core by
How can I get user type in an advanced theme without changing core?

In my case I need to show Sub-Nav only too admins and Moderatiors.

1 Answer

+2 votes
by
selected by
 
Best answer

You need to hide/unhide menu according to user role.

Add and modify nav_main_sub() function into your theme file

 

function nav_main_sub()
{
$this->nav('main');
$this->nav('sub');
}

 

Here you can internally use conditional display by using qa_get_logged_in_level(). So finally your code should be this

 

function nav_main_sub()
{
$this->nav('main');
 
if( qa_get_logged_in_level() > QA_USER_LEVEL_MODERATOR ) {
$this->nav('sub');
}
}
 
However there may be more way to do this like Scott has discribed in his answer here by using $post['level'] == 'Administrator' which is pretty stright forward and easy to remember. http://www.question2answer.org/qa/9995/method-for-identifying-moderators-admins-etc
 
After reading Gideon's answer http://www.question2answer.org/qa/6393/how-to-get-the-level-of-the-logged-in-user-in-a-theme  and digging into qa-app-users.php I found some other way to do which I alredy discribed in my code. Which is also alternate way to limit content by permission.
 
Hope this would be helpful to you and other people. Also post other way if you find.
by
Thanks, qa_get_logged_in_level()  worked.
...