Created
February 22, 2025 06:28
-
-
Save mehrshaddarzi/9d6bbf8e0d580f18726fcd4c02ed3d3c to your computer and use it in GitHub Desktop.
Digits Duplicate numbers user_login WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*$users = include WPMU_PLUGIN_DIR .'/wp_users.php'; | |
foreach($users as $user) { | |
$ID = $user['ID']; | |
$user_login = $user['user_login']; | |
echo $ID.'|'.$user_login.'|Done'; | |
$wpdb->update( | |
$wpdb->users, | |
array( | |
'user_login' => $user_login | |
), | |
array('ID' => $ID) | |
); | |
echo '<br />'; | |
}*/ | |
require_once( ABSPATH . 'wp-admin/includes/ms.php' ); | |
require_once(ABSPATH.'wp-admin/includes/user.php'); | |
$json = []; | |
$i = 1; | |
$users = $wpdb->get_results("SELECT ID,user_login FROM `wp_users`"); | |
foreach($users as $user) { | |
if(is_numeric($user->user_login) and strlen($user->user_login) and substr($user->user_login, 0, 2) == "98"){ | |
// check Has user | |
$get = get_user_by('login', substr($user->user_login, -10)); | |
if($get and $get->ID != $user->ID) { | |
$orders = get_posts(array( | |
'numberposts' => -1, | |
'meta_key' => '_customer_user', | |
'orderby' => 'date', | |
'order' => 'DESC', | |
'meta_value' => $user->ID, | |
'fields' => 'ids', | |
'post_type' => wc_get_order_types(), | |
'post_status' => array_keys(wc_get_order_statuses()), | |
)); | |
$new_orders = get_posts(array( | |
'numberposts' => -1, | |
'meta_key' => '_customer_user', | |
'orderby' => 'date', | |
'order' => 'DESC', | |
'meta_value' => $get->ID, | |
'fields' => 'ids', | |
'post_type' => wc_get_order_types(), | |
'post_status' => array_keys(wc_get_order_statuses()), | |
)); | |
// foreach($orders as $order_id) { | |
// update_post_meta($order_id, '_customer_user', $get->ID); | |
// delete_post_meta($order_id, '_customer_user_agent'); | |
// } | |
//if(empty($orders)) { | |
$json['list'][] = [ | |
'i' => $i, | |
'ID' => $user->ID, | |
'user_login' => $user->user_login, | |
'number_order' => $orders, | |
'saved' => substr($user->user_login, -10), | |
'New_id' => $get->ID, | |
'New_Number_Order' => $new_orders | |
]; | |
//wp_delete_user($user->ID); | |
$i++; | |
//} | |
} | |
} | |
$json['count'] = count( $json['list']); | |
} | |
echo json_encode($json); | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment