• Resolved -Aj-

    (@-aj-)


    Hi

    The backend dashboard widget will only show for the administrator, it does not show for the other roles I have enabled it for. It is not an option in the ‘screen options’ panel either (i.e. it’s not there at all, not just hidden).

    Under backend settings I have 3 other roles checked (author, editor, shop_manager), besides administrator which is ticked and *disabled* by default.

    It is my understanding that the plugin should use the roles within ga_dash_access_back to determine who to display the widget to

    Checking the debug log shows

    [ga_dash_access] => manage_options
        [ga_dash_access_front] => Array
            (
                [0] => administrator
            )
    
        [ga_dash_access_back] => Array
            (
                [0] => author
                [1] => editor
                [2] => shop_manager
            )

    I’ve even tried adding some debug logging breakpoints to tools->check_roles(), and they show that this is evaluating to ‘true’ for the users in question who are not receiving the dashboard..

    Any helps would be appreciated!

    Thanks

    Alex

    https://wordpress.org/plugins/google-analytics-dashboard-for-wp/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Your log looks fine. Also tested on my websites and is working ok.

    Do you use a security plugin that may restrict users?

    Thread Starter -Aj-

    (@-aj-)

    I’ve found the issue and resolved it – it was a cache issue, but part of the code in this plugin ‘enabled’ it.

    Runtime caches where causing the tools->check_roles() method to fail every time it was called AFTER the first due to your use of array_shift() on line 91 of tools.php

    The caches (W3-TC in this case) cache the value of $roles AFTER the shift so user capabilities ($roles) are essentially an empty array after the first operation. Not an issue with Admin users as they evaluate true based on the current_user_can( ‘manage_options’) and never actually check $roles.

    With the cache running this array_shift was actually removing the user roles in the WP_USER object ($current_user->roles), not just in the $roles variable, crazy!

    If you’re just using the 1st value of the array, then $roles[0] can get it ‘non destructively’ and will play nicer with caching, i’ve made this change to the plugin on my site and it now works fine that I’ve turned

    Thanks,

    Alex

    Nice, I’ll fix that in v4.2.20.

    The patch is available on github

    Thanks for your awesome feedback!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Role based backend settings not working’ is closed to new replies.