Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.8k views
in Themes by
Hai,

How can i redirect to differ pages for different level of users.The home page want to be different for different level of users.

thanks in advance

1 Answer

+2 votes
by
selected by
 
Best answer
Many ways to do it. Depending what exactly you are looking for. Here are some ideas...
 
You can use init_page so when user logged_in it will check and redirect...
 
// to redirect logged_in user based on role to questions page
public function init_page()
{
    // check user role
    if ( qa_get_logged_in_level() >= QA_USER_LEVEL_SUPER) {

        // redirect to the questions page
        return qa_redirect(qa_path('questions'));
    }

    // for multiple check you can use switch as well

    // only down point is no more grater value will be checked
    // but only for equal condition
    switch (qa_get_logged_in_level()) {
        case QA_USER_LEVEL_SUPER:
            return qa_redirect(qa_path('questions'));

        default:
            # code...
            break;
    }
}

 

This can be very tricky as you might need to write more code to perform what you exactly want.
 
The simple way I found is display content based on user role. For instance you want to switch content on main area. This should done in your theme file or plugin layer...
 
function main()
{

    if ( qa_get_logged_in_level() >= QA_USER_LEVEL_SUPER)
    {
        // add your stuffs
    } elseif ( qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN)
    {
        // add your stuffs
    } elseif ( qa_get_logged_in_level() >= QA_USER_LEVEL_MODERATOR)
    {
        // add your stuffs
    }

    // call this if you want to display default main() content
    #qa_html_theme_base::main();
}

Hope this will help you.

...