Support » Plugin: Statify » How to count logged in users + posts/sites set to private

  • Resolved axmann


    Hi there,

    I’m testing this plugin for just a few days but and I think I can say it does a great job so far.

    I’ve got two questions:

    1) How is it possible to count views by logged in users as well depending on their user role (e.g. each except admin)? I’ve checked the FAQ and found this thread but unfortunetly I haven’t enough coding skills to make the given example working.

    2) Is it possible to count views on posts/sites which are set to private as well? If yes, it would be great if you could provide a working code.


    Since it’s a german plugin I’d like to ask in german, too. So everyone should understand:

    1) Wie ist es möglich, eingeloggte User mitzuzählen und zwar anhand ihrer Benutzerrolle (z.B. alle außer Admins)?

    2) Ist es möglich, Beiträge und Seiten, die auf privat gesetzt sind, ebenfalls mitzuzählen?

    Kind regards / Viele Grüße

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Stefan Kalscheuer


    Hi axmann,

    Statify 1.7 will get a settings page to configure the filters without any custom code. Unfortunately current stable is still 1.6, so there is no such way.

    Second answer (by myself) in this topic contains a more sophisticated code snippet:

    (2) should be automatically solved when tracking authenticated users if you do not add additional filters, since private posts are just posts.

    You may copy the block to the end of your wp-config.php or the functions.php of your theme (if applicable).


    Plugin Author Patrick Robrecht


    Hi axmann,

    to count views per role, you’ll have to implement a filter similar to this one:

        function() {
            if (in_array('administrator', wp_get_current_user()->roles)) {
                return true;
            return false;

    You can put this in your theme’s functions.php or write a small plugin containing just the filter (recommended as theme updates won’t destroy your changes in this case).

    In this example only non-administrator would be logged (as the view is not logged if the skip filter returns true). Note that the code is untested.

    Regarding tracking private posts/pages: I think we don’t make a difference here. But by default, views by logged in users are not tracked – that’s why private posts/pages shouldn’t be tracked with the default settings. If you change the default tracking behavior, you can modify this.

    Kind regards

    Hi Stefan & Patrick,

    danke für eure schnellen Antworten und Hilfen. Ich konnte es leider noch nicht testen, aber ich denke, dass ich damit klar komme. Falls ihr nichts mehr von mir hört, ist alles ok. Finde, ihr macht mit euren Plugins einen super Job.

    English translation:

    Thanks for your quick help. Couldn’t test it yet but I think I can handle this. If you don’t hear from me again in this thread everything is fine. You and all of your plugins are doing a great job in my opinion.

    Kind regards / Viele Grüße


    Habe es gerade mit deinem Code von hier getestet, aber leider funktioniert es nicht. Hast du eine Idee?

    Just tested it with your code from here but it’s not working. Do you have an idea?

    • This reply was modified 3 months, 4 weeks ago by axmann.
    • This reply was modified 3 months, 4 weeks ago by axmann.
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.