Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
3.7k views
in Q2A Core by

Hi, I'm trying to make a widget only visible for admins.

The widget which I want to do that is the qa_activity_count

the file location is: qa-include --> qa-widget-activity-count.php

I tried to add this bit of code that I saw in the qa-page-admin-stats.php file but it doesn't work 

if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}

 

Q2A version: 1.6.3

1 Answer

+5 votes
by
edited by
 
Best answer
in the file qa-include --> qa-widget-activity-count.php 
 
search for the function output_widget and add the code inside the function 
 
if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
      // if level is less then the admin then dont print anything . 
      return "" ; 
}
For Example -- 
 
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) {
    /*
     SOME CODE HERE 
   */
    if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
           // if level is less then the admin then dont print anything . 
           return "" ; 
    }
   /*
         SOME CODE HERE ALSO 
   */
}
Hope This Helps . 
 
 
by
Awesome! exactly what I was looking for
...