Hide Post Views Count on back-end dashboard for multiple author website

Posted in: Newspaper
Post count: 30

Dear tagDiv Support,

I run a multiple author website, and I set JetPack only for Administrators and Editors. So I was sure that only Administrators and Editors were able to see stats.

Unfortunately, I discovered that in any case all users can see POST VIEWS COUNT on back-end dashboard.

I really cannot show this sensitive data to authors and collaborators, these are for me non-disclosable information.

So I pray you to support me in making proper changes to avoid that authors and collaborators can see Post Views Count on back-end dashboard. Only Administrators and maybe Editors can see them.

If not possible, I can also accept that no one can see Post Views Count (I can use Analytics, JetPack stats, etc), but it urges for me to hide these non-disclosable information.

Waiting your courteous reply,
Best Regards,
Marco M.

screen-td

  • This topic was modified 7 years by marclaude.
Post count: 30

Only Administrators and maybe Editors *should see post views count.

PS: I have updated right now the Newspaper theme to 9.7 (plugins included) and I have extended support for 1 year more.

Post count: 35449

Hi,

In order to show the views counter only for admin you need to set this custom code in wp-content/themes/Newspaper/functions.php
if ( !is_admin() ) {
echo "
<style>
#td_post_views
{
display: none;
}
</style>";
}

https://www.screencast.com/t/1XhDW6v4

Thank you!

Post count: 30

It doesn’t work, sorry!
I made the suggested changes but nothing happened.
As simple author, I can see views counter 🙁

td2
td1

Can you check it please?

Post count: 35449

Hi,

I checked that code again, and for me is working on the backed ( posts), but is look like is make some conflicts and change the fronted layout.
Please remove that code from theme file and try this one -> https://www.screencast.com/t/mBr94Famvr in wp-admin/edit.php
if( current_user_can( 'administrator' ) ){}else{
echo " <style> #td_post_views { display: none; } </style>";
}

Please make sure that you clear all cache

Thank you!

Post count: 30

Dear Calin,

I applied your suggestion, and it happens something strange: “Views” label disappeared, but the views count numbers are still there in their column, even if now it is an untitled column.

td5

Something wrong from my side?
Let me know,
Thank you and best regards,
Marco

Post count: 35449

Hi,

Please replace the code with this one
if( current_user_can( 'administrator' ) ){}else{
echo " <style> #td_post_views, .td_post_views, .column-td_post_views { display: none; } </style>";
}

Hope that this will work better!
Thanks.

Post count: 30

Yes! This solution works fine!
Thank you very much,
Have a nice weekend,
Marco

Viewing 8 posts - 1 through 8 (of 8 total)
The forum ‘Newspaper’ is closed to new topics and replies.