Jetpack from WordPress.com

I recently wrote a review and introduction to Jetpack with WordPress. I today discovered that non-admins (editors, even subscribers!) could see the Jetpack menu in the WordPress Dashboard. This for me is a bit of a no no and actually cannot believe it’s there! However it is fairly simple to remove it:


add_action( 'admin_menu', 'remove_menus' );

function remove_menus(){
if( !current_user_can( 'add_users' ) ){
remove_menu_page( 'jetpack' );
}
}

Stick that in your functions.php file and you’ll see Jetpack disappear for the mere mortals!

UPDATE 14/12/2012: It seems that the original hook indicated in the Codex was incorrect and should be “admin_menu” not “admin_init”. See here. I have updated the example above.

 Tagged with: , , , , ,

9 thoughts on “Quick Tip: Hide Jetpack from non-admins

  • I’ve tried the tip mentioned above, but as I am not really a programmer (only create visuals) I was stumped as to where to find the mysterious “functions.php”. Having found this in …/wp-includes/ I edited it by simply placing the obove lines prior to the PHP-Tag, As it turned out, that din’t work. Meanwhile I found a plug-in allowing for the exact funtion you described. It can be found in the Wordpess Plugins-Directory under http://wordpress.org/plugins/jetpack-only-for-admins/

     Reply

    • The functions.php refers to a file that should be inside your theme folder. Glad you got there with a plugin.

       Reply

  • I tested it with a non-admin user and although the options are gone but the menu itself is still there. Is there any way to COMPLETELY remove it?

     Reply

    • I haven’t really looked at Jetpack for quite a while, I think once WP3.6 is released properly i’ll have another look.

       Reply

  • I get a parse error when I add this to functions.php.
    Parse error: syntax error, unexpected T_FUNCTION

    I’m not a programmer (although I’m learning what I can). I just added this to the bottom of the file. Am I doing something wrong?

    Thanks!

     Reply

    • Sounds like you have a semi colon missing from somewhere probably on the line before the function starts. Other than that it’s hard to know what’s wrong without seeing your functions.php file

       Reply

  • thanks! worked perfectly!!

     Reply

  • Great tip, but shouldn’t the current_user_can function be looking for ‘install_plugins’?

     Reply

    • To be honest it’s personal preferences. That works for me.

       Reply

Leave a Reply

Mojowill Avatar

Who the Hell am I?

I'm Will, a full time web developer, geek and musician. I develop using PHP and MySQL and spend most of my time working with WordPress. When I'm not buried in code I'm gaming, cooking or writing and recording music in my studio. I like sci-fi, pancakes and coffee and am totally prepared for the zombie apocalypse...

Stalk me on these other sites...

Why not be super creepy and check me out on all these other sites, I think they call it social media?