bp_admin_repair_group_count ()

重新计算每个用户的组计数。

描述

返回

(数组)

文件:bp-core / admin / bp-core-admin-tools.php

函数bp_admin_repair_group_count(){全局$wpdb;如果(!Bp_is_active ('groups')) {return;} $statement = __('计算每个用户的组数…% s”、“buddyboss”);$result = __('失败!”、“buddyboss”);$sql_delete = "DELETE FROM {$wpdb->usermeta} WHERE meta_key IN ('total_group_count');";If (is_wp_error($wpdb->query($sql_delete)) {return array(1, sprintf($statement, $result));} $bp = buddypress();//浏览网站上的所有用户。 $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c; if ( $total_users > 0 ) { $per_query = 500; $offset = 0; while ( $offset < $total_users ) { // But only bother to update counts for users that have groups. $users = $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE is_confirmed = 1 AND is_banned = 0 AND user_id > %d AND user_id <= %d", $offset, $offset + $per_query ) ); foreach ( $users as $user ) { BP_Groups_Member::refresh_total_group_count_for_user( $user ); } $offset += $per_query; } } else { return array( 2, sprintf( $statement, $result ) ); } return array( 0, sprintf( $statement, __( 'Complete!', 'buddyboss' ) ) ); }

更新日志

更新日志
版本 描述
BuddyPress 2.0.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队