0

How to prevent sending auto emails for specific actions in wordpress, i have a function that generate password for users, only after the admin accept the user application

create_user_password($subscription->ID),
//this function calls wp_update_user

Wordpress sends a message about a (password change action), how to prevent this ONLY if this method was triggered by an admin

2

1 Answer 1

0

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');
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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