• Resolved albert0346

    (@albert0346)


    Hi,

    I want to exclude special people to be counted. How can I do it in the statify__skip_tracking function?

    Thanks in advance for your help.

    Albert

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Torsten Landsiedel

    (@zodiac1978)

    Hi @albert0346

    you can find the documentation for the filter here:
    https://statify.pluginkollektiv.org/documentation/hooks/#skip_tracking

    Do those people share something what can be used? Do you track logged-in users? Do they all have the same user role for example?

    Otherwise it will be not possible to detect the users … I think.

    All the best
    Torsten

    Thread Starter albert0346

    (@albert0346)

    Thanks Torsten!
    These are all people who give me data which I implement in the site.
    So I could give them a specific user role.
    But how can I then check in the function for this role?

    Albert

    Plugin Author Patrick Robrecht

    (@patrickrobrecht)

    Hi @albert0346,

    something like this:

    add_filter(
        'statify__skip_tracking',
        function( $previous_result ) {
            if ( current_user_can( 'edit_posts' ) ) {
                return true;
            }
    
            $user = wp_get_current_user();
    	if ( !empty( $user ) && in_array( 'administrator', $user->roles ) ) {
                return true;
            }
    
            return $previous_result;
        }
    );
    

    You can adjust the condition as you want by replacing the capability in current_user_can or the user role with the one.

    Thread Starter albert0346

    (@albert0346)

    Thanks Patrick!
    Yes, this CAN do it.

    Probably there is no other way that those people have to be logged in, right?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to exclude special people with the function statify__skip_tracking’ is closed to new replies.