WordPress.org

Ready to get started?Download WordPress

Forums

Analytics360
[resolved] Feature request: add filter hook to allow editors viewing stats (6 posts)

  1. brasofilo
    Member
    Posted 1 year ago #

    Hi,
    I always have to hack the plugin to allow editors to access the dashboard stats.

    I propose the following modifications:

    In function a360_request_handler:

    $cap = apply_filters( 'a360_dashboard_capability', 'manage_options' );
    	if (!empty($_GET['a360_action']) && current_user_can( $cap )) {

    In function a360_admin_menu:

    First, remove the wrapper current_user_can, as add_*_page already has a capability.

    And then use this to the dashboard page:

    add_dashboard_page(
    	__('Dashboard', 'analytics360'),
    	__('Analytics360°', 'analytics360'),
    	apply_filters( 'a360_dashboard_capability', 'manage_options' ),
    	basename(__FILE__),
    	'a360_dashboard'
    );

    http://wordpress.org/extend/plugins/analytics360/

  2. Alex King
    Member
    Plugin Author

    Posted 1 year ago #

    Good idea, you can create a pull request here:

    https://github.com/crowdfavorite/wp-analytics360

  3. HitchB
    Member
    Posted 9 months ago #

    Quiet an essential feature for many publishers like us.
    Can you please specify where exactly to insert the code, this is the only solution I found. Where to insert the function a360_request_handler exactly in the code?
    Appreciate your feedback.

  4. brasofilo
    Member
    Posted 9 months ago #

    @HitchB, I submitted a patch, hopefully it gets included in future releases.

    Meanwhile, you can change it in the file analytics360.php:

    - Change 2 occurrences of current_user_can in the function a360_request_handler.

    - And remove the if(current_user_can) from the function a360_admin_menu, and modify the capabilities for the dashboard page. It'll look like:

    function a360_admin_menu() {
        add_options_page(
             __('Settings', 'analytics360'),
             __('Analytics360°', 'analytics360'),
             'manage_options',
             basename(__FILE__),
             'a360_settings_form'
        );
        add_dashboard_page(
             __('Dashboard', 'analytics360'),
             __('Analytics360°', 'analytics360'),
             'manage_options', // <------ CHANGE HERE
             basename(__FILE__),
             'a360_dashboard'
        );
    }
  5. HitchB
    Member
    Posted 9 months ago #

    @Brasofilo: First of all, thanks a lot for your fast reply! I have been changing the file as requested. I simply copied the full file you submitted with the change you made. The menu appear now like this: http://awesomescreenshot.com/08a1tfcfcb

    Second, I don't understand why the menu item analytics 360 doesn't appear on our editor account:
    http://awesomescreenshot.com/05f1tfd110

    We also have the adminitize plugin installed as we manage a team of 30 writers plus 2 editors role. We want to display the analytics to our editors only. Do you have any idea why it doesn't work?

  6. HitchB
    Member
    Posted 9 months ago #

    I think it's something related to encoding 'Analytics 360°'

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic