The CyStats plugin is a great statistics plugin for WordPress. It has a ton of nice features, is easy to scan and displays all relevant stats (sans RSS feed stats) right from the WordPress backend.

The only problem I have is that it’s only viewable to registered WordPress users with an admin role. Editors, Authors and Contributors can access the WordPress backend, but can’t view the stats.

You could always install a bloated role manager plugin just so you can allow others to view CyStats. But this is overkill unless you need to adjust roles for some other reason.

Here’s a quick way to allow non-admin users to view your CyStats stats:

  1. In WordPress, go to Plugins > Editor
  2. Select CyStats from the upper right dropdown list
  3. Choose cystats/includes/admin.php from the list of plugin files on the right.
    Alternatively, FTP to the wp-content/plugins/cystats/includes/ dir and edit the admin.php file.
  4. Notice there are several ‘8‘s (or possibly ‘9‘s or ‘10‘s). These are the numbers for the WordPress user levels/roles. 8-10 are admins, 7-5 are editors, etc.:
    /**
     * Builds admin panem menu for Plugin
     */
    if(!function_exists('cystats_create_admin_menu')){
    	function cystats_create_admin_menu() {
    		if (function_exists('add_options_page')) {
    			add_options_page('CyStats Options Page', 'CyStats ', 8, 'cystats-options', 'cystats_admin_options');
    		}
    		if (function_exists('add_menu_page')) {
    			add_menu_page('CyStats Statistics Plugin', 'CyStats', 8, __FILE__, 'cystats_admin_index');
    		}
    		if (function_exists('add_submenu_page')) {
    			add_submenu_page(__FILE__, htmlspecialchars(__('CyStats: Index','cystats')), htmlspecialchars(__('Index','cystats')), 8, __FILE__, 'cystats_admin_index');
    			add_submenu_page(__FILE__, htmlspecialchars(__('CyStats: Blog','cystats')), htmlspecialchars(__('Blog','cystats')), 8, 'cystats-blog', 'cystats_admin_blog');
    			add_submenu_page(__FILE__, htmlspecialchars(__('CyStats: Clients','cystats')), htmlspecialchars(__('Clients','cystats')), 8, 'cystats-clients', 'cystats_admin_clients');
    			add_submenu_page(__FILE__, htmlspecialchars(__('CyStats: Referer','cystats')), htmlspecialchars(__('Referer','cystats')), 8, 'cystats-referer', 'cystats_admin_referer');
    			add_submenu_page(__FILE__, htmlspecialchars(__('CyStats: Robots & Tools','cystats')), htmlspecialchars(__('Robots/Tools','cystats')), 8, 'cystats-robots', 'cystats_admin_robots');
    			add_submenu_page(__FILE__, htmlspecialchars(__('CyStats: Pages','cystats')), htmlspecialchars(__('Pages','cystats')), 8, 'cystats-pages', 'cystats_admin_pages');
    			add_submenu_page(__FILE__, htmlspecialchars(__('CyStats: Time','cystats')), htmlspecialchars(__('Time','cystats')), 8, 'cystats-time', 'cystats_admin_time');
    			add_submenu_page(__FILE__, htmlspecialchars(__('CyStats: Options','cystats')),htmlspecialchars(__('Options','cystats')), 8, 'cystats-options', 'cystats_admin_options');
    		}
    	}
    }
  5. If you want editors (as well as admins) to be able to view the stats, change the 8, 9 or 10 throughout the includes/admin.php file to the number of the user level your want (ie 7, 6 or 5 for editors).
  6. If you only want the admin to be able to edit the CyStats options/settings (recommended), don’t change the final 8 (or 9 or 10). It looks like this:
    add_submenu_page(__FILE__, htmlspecialchars(__('CyStats: Options','cystats')),htmlspecialchars(__('Options','cystats')), 8, 'cystats-options', 'cystats_admin_options');

That’s it! No editing the database.

Note: You’ll probably need to make these changes again when you update the CyStats plugin, so this isn’t a perfect solution, but the CyStats plugin isn’t updated too often.

Enjoy.
{openx:7}

Similar Posts: