Disabling the update nag in WordPress

WordPress’ core update nag is quite the useful thing, I’ll usually know before it shows that there’s an update, but a lot of people won’t. If you don’t know what I mean with core update nag, it’s this thing:

core update nag

The issue is that this thing doesn’t only show to you, it shows to all users of your blog. Now there’s a plugin that will disable this for you, but it will disable it for everyone, yourself included.

A better thing to do, in my humble opinion, is either edit that plugin to have the following code, or add this code to your themes functions.php:

if ( !current_user_can( 'edit_users' ) ) {
  remove_action('admin_notices','update_nag',3);
}

This will show the nag to you, but prevent “normal” users from seeing it, saving you from a lot of email and allowing you to wait a few days before upgrading if you feel that’s wiser.

Disable update nag for certain users

Update, as asked by Kevin in the comments, here’s how to show them to a certain username, in this case “admin”:

global $user_login , $user_email;
get_currentuserinfo();
if ($user_login == "admin") {
  add_action('admin_notices','update_nag',3);
}

Update 19-9-2012 Updated for core changes to how the update nag works.

Tags:


Yoast.com runs on the Genesis Framework

Genesis theme frameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides you with the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Read our Genesis review or get Genesis now!

29 Responses

  1. LyndiBy Lyndi on 26 November, 2008

    Now this is very handy. Thanks.

  2. smotttBy smottt on 26 November, 2008

    Indeed very useful. Thanks for sharing this :)

  3. JayBy Jay on 26 November, 2008

    This is possibly a very bad idea. The nag is there for a reason, the correct thing to do is take the 5-10 minutes to simply update your version of wordpress. Don’t be LAZY! Do it an be done with it.

  4. Joost de ValkBy Joost de Valk on 26 November, 2008

    @Jay: you’re obviously not running 25+ blogs, or multi author blogs with more than 2 users. The email will kill you sometimes.

  5. JayBy Jay on 26 November, 2008

    @Joost I run a blog with multi-authors, but it’s only 2 blogs. I don’t run 25+ blogs though. So my statement applies to people with less than 25 blogs. :)

  6. KevinBy Kevin on 26 November, 2008

    What about making it show to a certain user id/name?

  7. Joost de ValkBy Joost de Valk on 26 November, 2008

    @Kevin: good question, updated the post!

    • frederickBy frederick on 19 June, 2009

      i tried your code to show update prompts to admin only, but it seems it was hiding from admin only. I changed =="admin" to !=="admin" and it worked for me. I also removed the reference to $user_email because I couldn’t see what it was there for.

      Here is the updated code that worked for me:


      global $user_login;
      get_currentuserinfo();
      if ($user_login !== "admin") {
      add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
      add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
      }

      p.s.
      i’m just a hack, i could never have written this from scratch and your code (with tweaks) works like a dream. thanks for the awesomeness!

  8. KevinBy Kevin on 26 November, 2008

    Wow that was fast – thanks!

  9. TertiusBy Tertius on 26 November, 2008

    Liking the userid/name.

    I had no idea that showed to multiple users!

  10. IanBy Ian on 27 November, 2008

    Thanks a lot. That was driving me crazy. I am content to wait until Godaddy updates and pushes the automated WordPress patches. I just don’t have time to mess with installing WP so frequently on multiple blogs. Keep up the good work.

  11. MartijnBy Martijn on 27 November, 2008

    That is a nice way of handling this !

    This nag has been bothering me for quite a while but just cutting it out of the code was too crude.

  12. AntonyBy Antony on 27 November, 2008

    I have just started to use WordPress2.6.5 and this is really cool.

  13. TomBy Tom on 27 November, 2008

    What about a plugin that instead of disabling the nag entirely gives you the option to ‘remind me later’ – and then re-nags 1 day, week or other amount later… Then it can also tell you how long you have procrastinated.

    I try to update when I can – but with a regular job, I can’t always get to it right away. Sometime I need to wait for the weekend.

  14. Michael HenryBy Michael Henry on 28 November, 2008

    Its about time there was a plugin for that. I use WordPress for a multi-author blog and there is one user who will email me every time she sees that message come up!

  15. gadgetBy gadget on 28 November, 2008

    Whilst we’re on the subject of 2.6.5 .. is it stable, time to wait or time to upgrade? I thought 2.7 was due out in Nov anyway?

  16. Nathan P.By Nathan P. on 30 November, 2008

    Thanks for the post. Interesting to say the least, I have to wait until cPanel updates it’s version, then update there. This would be nice so that only I know what the latest version number is.

  17. iskandarXBy iskandarX on 30 November, 2008

    Oh thats why I’m got notice for the update. Thanks for this tips.

  18. Shanker BakshiBy Shanker Bakshi on 1 December, 2008

    Thank god we don’t have to fight with these kinda things after 2.7 (auto upgrade system )

  19. Joost de ValkBy Joost de Valk on 2 December, 2008

    Thanks for all the comments!

    @Shanker: so right.

  20. Rajaie AlKoraniBy Rajaie AlKorani on 5 December, 2008

    Hey Joost,

    That’s a really good way, here’s another one I used to make mine disappear a few months ago: http://www.rajaietalks.com/how-to-get-rid-of-the-annoying-wordpress-update-nag

    Basically I made it go away by editing the CSS file.

    Rajaie

  21. HilmyBy Hilmy on 6 December, 2008

    Perhaps those with multiple blogs should consider using single installation such as virtual multiblog, wp mu, wp-hive plugin etc. There’s no more excuse as there’s only one set of codes to update. Not doing updates is simply too risky in some cases.

  22. Shelly ThomasBy Shelly Thomas on 7 December, 2008

    Thank you so much, I was not even aware anyone else could see that nag, which I hate but I guess it’s useful.

  23. GolfkursBy Golfkurs on 9 December, 2008

    Thank god we don’t have to fight with these kinda things after 2.7

  24. ShirleyBy Shirley on 9 December, 2008

    Great code sample. I often just use the plugin, but I prefer this method.
    @Rajaie, great CSS hack. I didn’t think of that either. :-)

  25. JabzBy Jabz on 12 December, 2008

    I did not know that. Just began to pickup WordPress again for several projects. The auto updater/ multiblog sounded good to me. A lot happened since my last WP install. :) Thanks for the fine news.

  26. TeMcBy TeMc on 30 June, 2009

    Hey, thanks a lot.

    Our WP-powered site runs a webshop (the awesome “wp-ecommerce” plugin) but that one is NOT compatible with WP 2.8.0 so therefor it was annoying that all Editors and Writers saw “There’s an update to WordPress, please contact the siteadministrator” – and I had to explain what’s going on.

    Leaving it on for me is fine.


    Thanks again,
    TEMC

  27. MarkBy Mark on 14 July, 2009

    Does this still work for 2.8 Joost?

    Not sure if a plugin could interfere with it but it does not seem to work on my 2.8.

    ?

  28. Jehzeel LaurenteBy Jehzeel Laurente on 20 October, 2009

    Exactly what I’m looking for. Thanks for this Joost! :)