Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

up vote 0 down vote accepted

You can only override pluggable functions in a plugin, not via functions.php. The function is already defined when functions.php is loaded, which is why your overriding function is skipped. Move the code to your own plugin to enable it.

share|improve this answer
    
Understood, thank you very much :D –  Cerere Sep 24 '12 at 16:10

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 the muplugins_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 Themes functions.php file - take TwentyTen/*Eleven as example.

<?php
! defined( 'ABSPATH' ) AND exit;
/** Plugin Name: (pluggable) Replace New User Notification function */

function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
    // define the functionality of your new function.
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.