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.

Let me know what you think on Mastodon, or BlueSky (or Twitter X if you must).

WordPress News

The latest WordPress updates from the WPBriefs Podcast.

Related Posts

14 Jun 2021

Take Control of WordPress Plugin and Theme Notifications

Plugin notifications have been a problem in WordPress for a long time now. Last week I saw a conversation on Slack where a developer said he thought they were getting out of hand, and then posted this screenshot:There’s a core...
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...
31 May 2007

WordPress tips and tricks – functions.php

Functions.php is a little known wordpress template file. Not many themes take advantage of it but , used properly, it can be incredibly powerful. The file can be used as a way to add your own functions to wordpress themes...
09 Jul 2010

Lowercase p, dangit! WordPress Controversy

There has recently been a new piece of code added to the WordPress core which makes sure that people spell WordPress correctly – automatically correcting misspellings (ie. making the P in the middle uppercase).On its own this seems harmless enough...
13 May 2010

6 Tips to Build Better WordPress Themes

If you want to make WordPress themes, for clients, to release for free or to sell, then there are a lot of factors you need to take into consideration. Below are some hints and tips that should help ease your...