Viewing 1 replies (of 1 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    By default, you can choose which user roles have access to your stats by going to Jetpack > Settings in your dashboard, and clicking on “Configure” next to the Stats module.

    You could also choose to allow a specific user to view your Stats, but you won’t be able to do it from the configuration screen. Instead, you’ll need to add this code to your theme’s functions.php file, or to a functionality plugin:

    function jeherve_add_stats_cap_user() {
            $user_id = '2'; // Enter the ID of the user who should have access to stats
            $user = new WP_User( $user_id );
    
            $user->add_cap( 'view_stats' );
    }
    add_action( 'admin_init', 'jeherve_add_stats_cap_user' );

    You can find the ID of the user by going to the Users menu in your dashboard, clicking on the user you’re interested in, and copying the user ID that appears in the URL.

    I hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Want to show to specific user’ is closed to new replies.