| 277 | * Repair signups table on non multisite configs |
| 278 | * |
| 279 | * If a signup is active = 0 and the user status is not 2, delete the signup |
| 280 | * |
| 281 | * @since BuddyPress (2.0.1) |
| 282 | */ |
| 283 | function bp_admin_repair_signups_table() { |
| 284 | global $wpdb; |
| 285 | |
| 286 | if ( is_multisite() ) |
| 287 | return; |
| 288 | |
| 289 | $statement = __( 'Reparing the signups table %s', 'buddypress' ); |
| 290 | $result = __( 'Failed!', 'buddypress' ); |
| 291 | |
| 292 | $signups_table = buddypress()->members->table_name_signups; |
| 293 | $sql['select'] = "DELETE FROM {$signups_table}"; |
| 294 | $sql['where'] = array(); |
| 295 | $sql['where'][] = "active = 0"; |
| 296 | |
| 297 | $pending_users = $wpdb->get_col( "SELECT user_login FROM {$wpdb->users} WHERE user_status = '2'" ); |
| 298 | |
| 299 | if ( ! empty( $pending_users ) ) { |
| 300 | $not_in = '"' . implode( '","', array_map( 'esc_sql', $pending_users ) ) .'"'; |
| 301 | $sql['where'][] = "user_login NOT IN ({$not_in})"; |
| 302 | } |
| 303 | |
| 304 | // Implode WHERE clauses |
| 305 | $sql['where'] = 'WHERE ' . implode( ' AND ', $sql['where'] ); |
| 306 | |
| 307 | $sql_delete = join( ' ', $sql ); |
| 308 | |
| 309 | if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) { |
| 310 | return array( 1, sprintf( $statement, $result ) ); |
| 311 | } else { |
| 312 | return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) ); |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | /** |