Skip to content

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.

Share

Join me, Frank, Ozh, Epic Alex. They're all chatting about "WordPress Tip: Modifying pluggable.php – How To Disable Emails" below ›

Read Comments

10 Comments »

  1. yes, maybe you will changes the messages from WordPress or you build a bridge with a other application, than its this file an great ressource.
    A small example do you find in my post, but only in german language and the code-snippets in default php ;)

  2. I love your first line in this post! After a year now on WP, I feel more overwhelmed than ever. They have great features, but I’m no tech guru and much of the time I wish I had the WP for Dummies manual to make sense of it all.

    Thanks for the tip on this feature. Much clearer now!

    Laura

  3. ” ‘the more I learn the less I know’? I often feel that way with WordPress!” this is so true, that I laughed!

    Nice article! pluggable.php is a very powerful set of functions, that is not ubiquitously known by the young, medium/young developers, but once you start to using the overriding logic in your devs, the sky is the limit.

    Cheers!

    MAC

Comments are closed. Let's continue the conversation on Twitter.