How to Override a Pluggable Function

How can I override a function in pluggable.php?

I have tried making my own plugin — got the fatal error on function already defined.

I tried functions.php in my theme — got the white screen.

Is it possible to override a pluggable.php function without touching the source code file itself?

Thanks.

Here is the function I wish to override (located in ../wp-includes/pluggable.php):

if ( !function_exists('wp_new_user_notification') ) :
/**
 * Notify the blog admin of a new user, normally via email.
 *
 * @since 2.0
 *
 * @param int $user_id User ID
 * @param string $plaintext_pass Optional. The user's plaintext password
 */
function wp_new_user_notification($user_id, $plaintext_pass="") {
...
}

2 s
2

Wrap it in a function_exists check:

if( ! function_exists('some_pluggable_function') ) {
    function some_pluggable_function()
    }
}

Leave a Comment