From 86bc0072b152858de46d28e43cf0138e3af4541b Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 18 Sep 2024 14:06:10 +0300 Subject: [PATCH] Switch to a core helper --- class-two-factor-core.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/class-two-factor-core.php b/class-two-factor-core.php index 575ed43b..fa87135e 100644 --- a/class-two-factor-core.php +++ b/class-two-factor-core.php @@ -182,23 +182,8 @@ public static function uninstall() { } } - /** - * Get all user IDs to delete their user meta. - * - * Consider replacing this with a direct SQL query to speed up the process. - */ - $user_ids = get_users( - array( - 'blog_id' => 0, // Return all users. - 'fields' => 'ID', - 'number' => -1, // This might take a while on larger sites but we have only one uninstall hook to run this. - ) - ); - - foreach ( $user_ids as $user_id ) { - foreach ( $user_meta_keys as $meta_key ) { - delete_user_meta( $user_id, $meta_key ); - } + foreach ( $user_meta_keys as $meta_key ) { + delete_metadata( 'user', null, $meta_key, null, true ); } }