Title: Override WP function = Cannot redeclare function
Last modified: December 11, 2020

---

# Override WP function = Cannot redeclare function

 *  Resolved [CaptainMorgan](https://wordpress.org/support/users/davehealey/)
 * (@davehealey)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/override-wp-function-cannot-redeclare-function/)
 * I’m trying to override the wp_password_change_notification function using the
   below code but I’m getting the Cannot redeclare error. Is there a solution?
 *     ```
       if ( !function_exists( 'wp_password_change_notification' ) ) {
           function wp_password_change_notification() {}
       }
       ```
   

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

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/override-wp-function-cannot-redeclare-function/#post-13774987)
 * Hi [@davehealey](https://wordpress.org/support/users/davehealey/),
 * This is a known bug in the current version. It will be fixed in the next release.
 *  Thread Starter [CaptainMorgan](https://wordpress.org/support/users/davehealey/)
 * (@davehealey)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/override-wp-function-cannot-redeclare-function/#post-13781663)
 * Ok, thanks, I’ll wait for the next version 🙂
 *  [seanjohn86](https://wordpress.org/support/users/seanjohn86/)
 * (@seanjohn86)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/override-wp-function-cannot-redeclare-function/#post-14079168)
 * Should this still be happening? I’m using version 2.14.0 of the Code Snippets
   plugin (WordPress is 5.5.3 if that matters).
 * Snippet is a little bit different but the same thing is happening. I’ve tried
   using a few different versions of this code and they all seem to give the same
   error:
 * > [View post on imgur.com](https://imgur.com/a4eKF4m)
 *  [Steve](https://wordpress.org/support/users/steveholland/)
 * (@steveholland)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/override-wp-function-cannot-redeclare-function/#post-14147729)
 * I have no idea why, but the following code is not working and it’s driving me
   nuts!
 * I am getting 10 or more “Password Changed” emails per day on an active website.
 *     ```
       if (!function_exists('wp_password_change_notification')) {
           function wp_password_change_notification($user) {
           return;
           }
       }
       ```
   
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/override-wp-function-cannot-redeclare-function/#post-14148958)
 * Hi [@steveholland](https://wordpress.org/support/users/steveholland/),
 * Are you getting the same error when you try to save this snippet? If not, and
   it’s just that the code isn’t working, then please start a new thread in this
   forum and I’ll do my best to help you out.
 *  Thread Starter [CaptainMorgan](https://wordpress.org/support/users/davehealey/)
 * (@davehealey)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/override-wp-function-cannot-redeclare-function/#post-14242784)
 * I’m no longer getting the error but the snippet isn’t working for me. I’m still
   getting password changed emails.
 *  Thread Starter [CaptainMorgan](https://wordpress.org/support/users/davehealey/)
 * (@davehealey)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/override-wp-function-cannot-redeclare-function/#post-14261544)
 * Actually it seems to be working now, maybe I forgot to hit apply

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

The topic ‘Override WP function = Cannot redeclare function’ 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/)

## Tags

 * [cannot redeclare](https://wordpress.org/support/topic-tag/cannot-redeclare/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [password](https://wordpress.org/support/topic-tag/password/)

 * 7 replies
 * 4 participants
 * Last reply from: [CaptainMorgan](https://wordpress.org/support/users/davehealey/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/override-wp-function-cannot-redeclare-function/#post-14261544)
 * Status: resolved