Customized wp_new_user_notification
I’m kind of inexperienced with it comes to editing WordPress functions, yet i’m currently trying to customize wp_new_user_notification
in order to personalize the email that administrators and users receive once they register. I’m aware there’s some plugins that allow this kind of customization, but I would rather spend some more time on a problem and try to learn/understand it, rather than just install a plugin.
Hence, I’ve placed this function in my functions.php
, and I believe I’m supposed to add one or more filters, such as:
add_filter('myfunction', 'wp_new_user_notification', ?, ?)
or maybe not. I’ve read and attempted to follow several tips/tutorials/questions (such as for example), but no matter what I do, I keep receiving emails with standard text/contents (as if my functions is not being considered by WordPress).
Can anyone help me solve this problem? Thanks in advance!
You can only override pluggable functions in a plugin, not via
functions.php
. The function is already defined whenfunctions.php
is loaded, which is why your overriding function is skipped. Move the code to your own plugin to enable it.When do Plugins load?
Plugins are loaded right before the
plugins_loaded
hook. MU-Plugins (this is what every pluggable imho should be), are loaded even earlier, before themuplugins_loaded
-hook. (Both are the first hooks for plugins and run much earlier than every hook accessible for themes).What exactly are Pluggables?
“Pluggables” are called like this, because they can get “plugged out” in core and replaced. This happens, because they are wrapped in a
if ( ! function_exists( 'some_pluggable_fn' ) ) {
calls.You can find the im
pluggable.php
in core or sometimes in a Themesfunctions.php
file – take TwentyTen/*Eleven as example.