I can disable a filter as follows:

add_filter( 'send_password_change_email', '__return_false' );

This may be a trivial question, but I can't find an answer for it... can I re-enable the filter with the following?

add_filter( 'send_password_change_email', '__return_true' );

If not, how can I re-enable a filter?

  • Just comment out or remove this line.
    – nmr
    Apr 12 '19 at 13:55
  • For this specific instance, I want to disable sending the standard WP password changed email while a function runs and then re-enable it. Apr 12 '19 at 14:42
  • put remove_filter( 'send_password_change_email', '__return_false' ); at the end of the function?
    – majick
    Apr 12 '19 at 15:32

When you add functions to the same handle without specifying the priority, they are executed in the order of addition. Every time you try to send an email, all the hooked functions will be called in the order in which they were added.

To turn on email sending while a function runs, you can:

  • remove __return_false from filter at the beginning of the function and add again at the end,
  • add __return_true to filter (will be executed as second and override previous result) at the beginning of the function and remove it at the end.


function my_function() 
    add_filter( 'send_password_change_email', '__return_true' );
    // sending an email about password change enabled
    remove_filter( 'send_password_change_email', '__return_true' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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