How to prevent sending auto emails for specific actions in wordpress

If you look in the documentation of wp_update_user() you will see that it uses two filters:

  • send_password_change_email
  • send_email_change_email

Simply from the names I would guess if you return false in send_password_change_email it should work. So something along the lines of:

function create_user_password($id) {
    // other code
    add_filter('send_password_change_email', '__return_false');
    wp_update_user(...);
    remove_filter('send_password_change_email', '__return_false');
}

tech