7fc9b363 by Marty Penner

Changed search users (for merge) SQL (once again) to ORDER BY first and last nam…

…es, as well as refactored checks for profile preference and email addresses to merge to new user
1 parent ed9f5fa5
......@@ -1013,7 +1013,7 @@ class Actions {
OR umm.meta_value LIKE '%$username%')
AND ums.meta_value != 'terminated'
)
ORDER BY user_email";
ORDER BY first_name, last_name";
$result = $wpdb->get_results($query, ARRAY_A);
......@@ -1096,8 +1096,6 @@ HTML;
'comment_shortcuts',
'admin_color',
'use_ssl',
'wp_capabilities',
'wp_user_level',
'x_cicbv.person',
'tz_profile_pub',
'events',
......@@ -1118,10 +1116,16 @@ HTML;
continue;
}
// Special case: only transfer member_id if it's not blank
// Special cases:
// Only transfer member_id if it's not blank
if ($key == 'member_id' && empty($val)) {
continue;
}
// Don't transfer any wp_* fields
if (substr($key, 0, 3) == 'wp_') {
continue;
}
// Make sure we're updating the right user ID and perform update
update_user_meta($to_user->ID, $key, $val);
......@@ -1132,7 +1136,13 @@ HTML;
// Transfer old user's profile preference email address (work, home, etc.) to new user's user_email field
if (isset($from_user->profile_preference) && ! empty($from_user->profile_preference)) {
$preference = strtolower($from_user->profile_preference) . '_email';
if (isset($from_user->$preference) && ! empty($from_user->$preference)) {
_update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->$preference));
} else {
_update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->user_email));
}
} else {
_update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->user_email));
}
}
......