Stats: Changing settings for custom user roles does not work
Originally reported here: https://wordpress.org/support/topic/setting-to-count-logged-in-page-views-from-customers-does-not-stick/
I was able to reproduce this on my test site. I have several custom roles:
I can click one of them and Activate it, and I get a green success message. However, when I refresh the page, the role is deactivated again.
Does this happen in the old Jetpack > Site Stats > Configure page, or is the problem the same there as well?
Interesting question! So it turns out that some of the roles are already active there:
If I activate "Employer" it stays checked on that page; if I then go to the new Config screen, I see that it's still not active there.
If I deactivate the 3 custom roles on the old page, and then activate it on the new page, it gets activated on the old page as well. However, if I refresh the new page, it still doesn't appear activated, though it remains activated on the old page on refresh.
So, tl;dr is that the new page does not properly show the activation setting for custom roles (and custom roles only; I tested several default roles and they all worked as expected).
This issue has been marked as stale. This happened because:
- It has been inactive in the past 6 months.
- It hasn’t been labeled `[Pri] Blocker`, `[Pri] High`.
No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.
As noted in 3526-gh-jpop-issues, this also affects changing which roles can view stats reports. Ticket from that issue is 1789238-zen.
In reference to 1789238-zen
The settings for which roles can view stats reports are actually changing, however custom users are still not able to view stats regardless of the change.
Hi, this also leads to situation that only administrators are capable of using the woocommerce mobile app to view shop statistics. No custom roles for example by woocommerce (shop manager) are capable of viewing the shop statistics via WOO mobile app or via wordpress.com only site administrators.
@Ilardo Until this gets fixed I would recommend that you use the old Stats configuration screen (Jetpack > Site Stats > Configure) to change the stats access options. That should work.
@Ilardo Until this gets fixed I would recommend that you use the old Stats configuration screen (Jetpack > Site Stats > Configure) to change the stats access options. That should work.
Hi, Thanks for your suggestion but i have tested this and this is only saving this option but there is no difference in behaviour for the custom role. So the old settings page save the settings but does not actually make any change in privileges.
Thanks for letting us know, that's helpful!
1924926-zen
https://wordpress.org/support/topic/site-stats-can-not-be-used-by-custom-roles/
A VIP user bumped into this as well (96297 for my reference). I'm seeing references to the "old Configure" page in this thread and in others:
Does this happen in the old Jetpack > Site Stats > Configure page, or is the problem the same there as well?
When I visit example.com/wp-admin/admin.php?page=jetpack#/settings?term=Site%20Stats in JP 5.2.2, I'm only presented with the new interface. Is there a way to still access the old interface or a workaround to use to enable stats for custom user roles while this is being worked on?
Is there a way to still access the old interface or a workaround to use to enable stats for custom user roles while this is being worked on?
We removed that old stats configuration page from Jetpack a few versions ago, so I am afraid there is no UI workaround right now.
Just a note that I found that this is still happening in VIP Go sites. But I also found that the old set up seems lost for clients, for instance in http://example.com/wp-admin/admin.php?page=jetpack#/traffic. When updating, I get success for the Allow stats reports to be viewed by and an error on Count logged in page views from, and the updates don't stick on refreshing.
96297-zd-wordpressvip 98659-zd-wordpressvip 100987-zd-wordpressvip
poqVs-n48-p2#comment-124366
The problem still there
2997907-zen
Settings in WordPress.com works correctly but in wp-admin, the custom role toggle does not show it's correct value.
This is still a current issue for VIP sites with custom roles.
VIP: (#114669-z)
Here are my findings:
Default roles
- Wworks as expected. You can toggle active/deactive and everything runs smoothly.
Custom roles
- The initial toggle active works. It updates
stats_options. - On page refresh the toggle shows deactive even though
stats_optionshas been updated. - Changing the toggle setting doesn't update
stats_options.
You can still update the setting with CLI.
Get the roles which have Stats permission, for example:
wp option pluck stats_options roles
array (
0 => 'administrator',
1 => 'custom-role',
)
And then delete custom-role with:
wp option patch delete stats_options roles 1
Success: Updated 'stats_options' option.
After some more testings, I've discovered that if you don't refresh the page, you can deactivate the role - this works after the initial page refresh too. Workflow:
Step 1: Go to /wp-admin/admin.php?page=jetpack#/settings?term=Site Stats and activate custom role.
=> You get settings updated message and option stats_options is updated.
Step 2: Hard refresh the page, try to deactivate the same custom role which shows as deactive.
=> You get settings updated message and stats_options stays the same.
Step 3: Do not refresh the page, and now with the custom role showing as active, deactivate that custom role.
=> You get settings updated message, the role now shows deactivated and option stats_options has been updated by removing the role.
We've got a report of this on 4842500-zen with a user using WooCommerce custom-roles.