Title: Pluggable functions?
Last modified: September 7, 2016

---

# Pluggable functions?

 *  Resolved [wekhter](https://wordpress.org/support/users/wekhter/)
 * (@wekhter)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/pluggable-functions-2/)
 * I had the following code active on my site as a plugin:
 *     ```
       if ( !function_exists( 'wp_password_change_notification' ) ) {
        function wp_password_change_notification() {}
       }
       ```
   
 * (this code prevents the admin from getting email notifications when users change
   their passwords)
 * I moved this code from the plugin to a Code Snippet and the admin received a 
   password change notification a few minutes later. Can Code Snippets not modify
   pluggable functions?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [wekhter](https://wordpress.org/support/users/wekhter/)
 * (@wekhter)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/pluggable-functions-2/#post-8249230)
 * I know it’s been several weeks but I’m still wondering about this
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/pluggable-functions-2/#post-8254809)
 * Sorry, I have been meaning to have a look at this, but I have yet to figure out
   a solution. It’s possible that snippets are running after pluggable.php is loaded,
   and so the function is already defined before the snippet has a chance to redefine
   it. It may also be an issue with how I’m getting PHP to execute the snippet code.
   I’ll keep searching for a fix and let you know what I figure out.
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/pluggable-functions-2/#post-8539314)
 * Okay, so I now know what’s causing this issue. Basically, there’s nothing preventing
   you overriding pluggable functions with snippets. The issue is that the functions
   in `wp-includes/pluggable.php` are loaded _before_ any of the snippets are loaded,
   so they have already been defined before you have a chance to define them.
 * For an example, trying to redefine the `get_avatar()` function like so will not
   work, as it will have already been defined before the snippet is evaluated:
 *     ```
       if ( ! function_exists( 'get_avatar ) ) {
       	function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false )	 {
       		return '🙂';
       	}
       }
       ```
   
 * But redefining a pluggable function which is defined after plugins and snippets
   have loaded, such as one from Twenty Sixteen, will work perfectly fine:
 *     ```
       if ( ! function_exists( 'twentysixteen_entry_meta' ) ) {
       	function twentysixteen_entry_meta() {
       		echo 'overrides entry meta';
       	}
       }
       ```
   
 * Unfortunately, I don’t think there’s much I can do to allow overriding built-
   in pluggable functions at this stage, but hopefully I will soon be able to restructure
   the snippet evaluation system to be more flexible and allow snippets to run earlier
   in the load process.
    -  This reply was modified 9 years, 6 months ago by [Shea Bunge](https://wordpress.org/support/users/bungeshea/).
      Reason: minor formatting fix

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Pluggable functions?’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/pluggable-functions-2/#post-8539314)
 * Status: resolved