f5073b5a by Marty Penner

Cleaned up search and merge functionality

1 parent fa978a0c
......@@ -985,7 +985,7 @@ class Actions {
$query = "
SELECT ID, user_email
FROM $wpdb->users
WHERE
WHERE (
(user_login LIKE '%$username%')
OR (user_email LIKE '%$username%')
OR (ID IN (
......@@ -993,7 +993,7 @@ class Actions {
FROM $wpdb->usermeta
WHERE (meta_key = 'first_name' OR meta_key = 'last_name')
AND meta_value LIKE '%$username%'
))
)))
AND (ID NOT IN (
SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'status' AND meta_value = 'terminated'
))
......@@ -1049,21 +1049,23 @@ HTML;
$html = '';
$from_user = new User\Account($_POST['merge_user_from']);
$to_user = new User\Account($_POST['merge_user_to']);
// These fields are skipped ONLY IN DISPLAY
$skipped_fields = array(
'ID',
'id',
'user_login',
'user_pass',
'user_nicename',
'user_email',
'member_id',
'user_url',
'user_registered',
'user_activation_key',
'user_status',
'display_name',
'id',
'caps',
'cap_key',
'roles',
'allcaps',
'filter',
'user_pass',
'user_activation_key',
'status',
'four_security_expiration',
'course_4q_approvals',
......@@ -1101,13 +1103,19 @@ HTML;
if ($key == 'member_id' && empty($val)) {
continue;
}
// Make sure we're updating the right user ID and perform update
update_user_meta($to_user->ID, $key, $val);
// Build a table of data
$html .= "\n\t<tr><td>$key: $val</td></tr>";
}
if (! empty($from_user->user_email)) {
// 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';
_update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->$preference));
}
}
// Set a few meta values for the old user
update_user_meta($from_user->ID, 'status', 'terminated');
......