WordPress Tip: Modifying pluggable.php – How To Disable Emails

Ever heard the saying, ‘the more I learn the less I know’? I often feel that way with WordPress! I like to think that my knowledge of WordPress is above average, but I keep learning new things, and they keep on changing it. My most recent ‘discovery’ is pluggable.php.

Pluggable.php is a php file full of a variety of WordPress functions. I was aware of its existence but until recently I didn’t understand it’s significance. The key thing that makes pluggable.php useful is that all the functions are wrapped in ‘if function_exists‘ calls. This means that you can plug-in (hence the name I guess) your own versions to override the default WordPress functionality.

The reason I found out about this is because I was searching for a way to stop myself from receiving emails when a new user signed up for WordPress Vote. When you have a public site you don’t always want to receive these notifications and so I headed over to Twitter and got the following message from mfields.

The function in question is wp_new_user_notification. In order to stop the emails all I have to do is create a new function with the same name inside my functions.php. If I do this then, because the function already exists, the built-in functionality doesn’t get executed. It couldn’t be easier.

Functions

Reading through pluggable.php there are a few different functions in there that it may be useful to override at some time and I have included the ones I find most interesting below. You can read the full list of functions on the pluggable.php code browser on WordPress trac.

  • wp_new_user_notification and wp_password_change_notification – these are the reason I first looked into pluggable.php. You can add blank functions to remove the notifications or you could change the email message or email destination to make them more useful.
  • wp_generate_password – create your own password generation algorithm
  • get_avatar – change the avatar system to use services other than Gravatar (are there any others?)

Your Ideas?

Pluggable.php isn’t the solution to everything however, as with many things, this is another string to add to your bow. It’s certainly not going to solve all of your WordPress problems, but if there’s something you are not sure about then it could be worth checking out.

Had you looked at pluggable.php before? I’d be interested to know what you are overriding and why.

How was it for you? Let me know on BlueSky or Mastodon

(Please) Link to this page

Thanks for reading. I'd really appreciate it if you'd link to this page if you mention it in your newsletter or on your blog.

Related Posts

23 Aug 2020

Pixel Avatars; a Privacy first Gravatar replacement

Recently Justin Tadlock posted on the WP Tavern about the WordPress Privacy teams plans for local avatars in WordPress to improve privacy options in core WordPress.I’ve been thinking about making my own avatar system for years. I like doing creative...
27 May 2013

WordPress: 10 Years Young, What Does The Future Hold?

WordPress is now 10 years old. I started using wordpress 9 years ago – which means I joined the WordPress community early on. The reason I chose WordPress is simply because of the fabled 5 minute install process – I...
20 Feb 2013

The Amazing Art of Flipping Websites

Recently I have looked at expanding my internet empire. I have all sorts of ideas and never enough time – so I thought I would see if I could buy some websites relatively cheaply, improve them, and then either flip...
14 May 2013

Redesigning the WordPress Post Editor

Ghost is a project born from frustration with WordPress. Ironically it seems to be mostly WordPress power users who want to use it. The Ghost team – led by John O’Nolan – put Ghost on KickStarter last week and it...
26 Nov 2016

Generating a WordPress rtl.css with Gulp

Generating a rtl.css files is something I don’t enjoy doing. I think it’s really important that they are created since a large proportion of the world uses rtl (right to left) languages. But they are a bit of a pain...
13 Jul 2016

Why My WordPress Themes Site Doesn’t Use WordPress

I’ve mentioned it before but I run a WordPress themes site called Pro Theme Design. On it, I sell premium WordPress themes – but I don’t use WordPress to power the site.This probably seems like a strange thing to do...