Users filtering not working on multisite
-
I am writing about this ticket https://www.ads-software.com/support/topic/users-filtering-not-working-on-multisite/ as it has not been resolved and the problem persists.
I fixed it myself, but after updating the plugin, my fix is removed. Can you replace the following code into the plugin in the path new-user-approve/includes/user-list.php(line 225)?
$query->query_from .= " INNER JOIN {$wpdb->usermeta} ON ( {$wpdb->users}.ID = $wpdb->usermeta.user_id )"; if ( 'approved' == $filter ) { $query->query_fields = "DISTINCT SQL_CALC_FOUND_ROWS {$wpdb->users}.ID"; $query->query_from .= " LEFT JOIN {$wpdb->usermeta} AS mt1 ON ({$wpdb->users}.ID = mt1.user_id AND mt1.meta_key = 'pw_user_status')"; $query->query_where .= " AND ( ( $wpdb->usermeta.meta_key = 'pw_user_status' AND CAST($wpdb->usermeta.meta_value AS CHAR) = 'approved' ) OR mt1.user_id IS NULL )"; } else { $query->query_where .= " AND ( ($wpdb->usermeta.meta_key = 'pw_user_status' AND CAST($wpdb->usermeta.meta_value AS CHAR) = '{$filter}') )"; }
to this:
if (is_multisite() && is_user_logged_in()) { if ('approved' === $filter) { $query->query_from = "FROM wp_users LEFT JOIN wp_usermeta ON ( wp_users.ID = wp_usermeta.user_id ) LEFT JOIN $wpdb->usermeta AS mt1 ON ( wp_users.ID = mt1.user_id AND mt1.meta_key = 'pw_user_status' ) LEFT JOIN $wpdb->usermeta AS mt2 ON ( wp_users.ID = mt2.user_id )"; $query->query_where = ''; $query->query_where .= " WHERE 1=1 AND ( ( ( ($wpdb->usermeta.meta_key = 'pw_user_status' AND CAST($wpdb->usermeta.meta_value AS CHAR) = '{$filter}') OR mt1.user_id IS NULL ) AND ( mt2.meta_key = '{$wpdb->prefix}capabilities' ) ) ) GROUP BY wp_users.ID "; } else { $query->query_where = ''; $query->query_where .= " AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' INNER JOIN wp_usermeta as wp_usermeta1 ON ( wp_users.ID = wp_usermeta1.user_id ) AND ( ( wp_usermeta1.meta_key = 'pw_user_status' AND CAST(wp_usermeta1.meta_value AS CHAR) = '{$filter}' ) ) "; } } else { $query->query_from .= " INNER JOIN {$wpdb->usermeta} ON ( {$wpdb->users}.ID = $wpdb->usermeta.user_id )"; if ('approved' == $filter) { $query->query_fields = "DISTINCT SQL_CALC_FOUND_ROWS {$wpdb->users}.ID"; $query->query_from .= " LEFT JOIN {$wpdb->usermeta} AS mt1 ON ({$wpdb->users}.ID = mt1.user_id AND mt1.meta_key = 'pw_user_status')"; $query->query_where .= " AND ( ( $wpdb->usermeta.meta_key = 'pw_user_status' AND CAST($wpdb->usermeta.meta_value AS CHAR) = 'approved' ) OR mt1.user_id IS NULL )"; } else { $query->query_where .= " AND ( ($wpdb->usermeta.meta_key = 'pw_user_status' AND CAST($wpdb->usermeta.meta_value AS CHAR) = '{$filter}') )"; } }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Users filtering not working on multisite’ is closed to new replies.