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
Showing
1 changed file
with
15 additions
and
5 deletions
| ... | @@ -1013,7 +1013,7 @@ class Actions { | ... | @@ -1013,7 +1013,7 @@ class Actions { |
| 1013 | OR umm.meta_value LIKE '%$username%') | 1013 | OR umm.meta_value LIKE '%$username%') |
| 1014 | AND ums.meta_value != 'terminated' | 1014 | AND ums.meta_value != 'terminated' |
| 1015 | ) | 1015 | ) |
| 1016 | ORDER BY user_email"; | 1016 | ORDER BY first_name, last_name"; |
| 1017 | 1017 | ||
| 1018 | $result = $wpdb->get_results($query, ARRAY_A); | 1018 | $result = $wpdb->get_results($query, ARRAY_A); |
| 1019 | 1019 | ||
| ... | @@ -1096,8 +1096,6 @@ HTML; | ... | @@ -1096,8 +1096,6 @@ HTML; |
| 1096 | 'comment_shortcuts', | 1096 | 'comment_shortcuts', |
| 1097 | 'admin_color', | 1097 | 'admin_color', |
| 1098 | 'use_ssl', | 1098 | 'use_ssl', |
| 1099 | 'wp_capabilities', | ||
| 1100 | 'wp_user_level', | ||
| 1101 | 'x_cicbv.person', | 1099 | 'x_cicbv.person', |
| 1102 | 'tz_profile_pub', | 1100 | 'tz_profile_pub', |
| 1103 | 'events', | 1101 | 'events', |
| ... | @@ -1118,10 +1116,16 @@ HTML; | ... | @@ -1118,10 +1116,16 @@ HTML; |
| 1118 | continue; | 1116 | continue; |
| 1119 | } | 1117 | } |
| 1120 | 1118 | ||
| 1121 | // Special case: only transfer member_id if it's not blank | 1119 | // Special cases: |
| 1120 | // Only transfer member_id if it's not blank | ||
| 1122 | if ($key == 'member_id' && empty($val)) { | 1121 | if ($key == 'member_id' && empty($val)) { |
| 1123 | continue; | 1122 | continue; |
| 1124 | } | 1123 | } |
| 1124 | // Don't transfer any wp_* fields | ||
| 1125 | if (substr($key, 0, 3) == 'wp_') { | ||
| 1126 | continue; | ||
| 1127 | } | ||
| 1128 | |||
| 1125 | // Make sure we're updating the right user ID and perform update | 1129 | // Make sure we're updating the right user ID and perform update |
| 1126 | update_user_meta($to_user->ID, $key, $val); | 1130 | update_user_meta($to_user->ID, $key, $val); |
| 1127 | 1131 | ||
| ... | @@ -1132,7 +1136,13 @@ HTML; | ... | @@ -1132,7 +1136,13 @@ HTML; |
| 1132 | // Transfer old user's profile preference email address (work, home, etc.) to new user's user_email field | 1136 | // Transfer old user's profile preference email address (work, home, etc.) to new user's user_email field |
| 1133 | if (isset($from_user->profile_preference) && ! empty($from_user->profile_preference)) { | 1137 | if (isset($from_user->profile_preference) && ! empty($from_user->profile_preference)) { |
| 1134 | $preference = strtolower($from_user->profile_preference) . '_email'; | 1138 | $preference = strtolower($from_user->profile_preference) . '_email'; |
| 1135 | _update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->$preference)); | 1139 | if (isset($from_user->$preference) && ! empty($from_user->$preference)) { |
| 1140 | _update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->$preference)); | ||
| 1141 | } else { | ||
| 1142 | _update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->user_email)); | ||
| 1143 | } | ||
| 1144 | } else { | ||
| 1145 | _update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->user_email)); | ||
| 1136 | } | 1146 | } |
| 1137 | } | 1147 | } |
| 1138 | 1148 | ... | ... |
-
Please register or sign in to post a comment