标签: BuddyPress, 列表, 成员, 用户, 隐藏
正在查看 9 个帖子:1-9 (共 9 个帖子)
-
作者帖子
-
在 buddypress 的用户列表中,会显示管理员,请问如何隐藏呢?只显示用户,不显示 admin?
谢谢!
将以下代码放在 (子) 主题的 functions.php 文件里即可。
/** * Exclude Users from BuddyPress Members List by WordPress role. * 从 BuddyPress 成员列表中排除特定 WordPress 角色的成员。 * * @param array $args 参数 * * @return array */ function buddydev_exclude_users_by_role( $args ) { // do not exclude in admin. if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { return $args; } $excluded = isset( $args['exclude'] ) ? $args['exclude'] : array(); if ( ! is_array( $excluded ) ) { $excluded = explode( ',', $excluded ); } $role = 'administrator';// 要排除的用户权限 change to the role to be excluded. $user_ids = get_users( array( 'role' => $role, 'fields' => 'ID' ) ); $excluded = array_merge( $excluded, $user_ids ); $args['exclude'] = $excluded; return $args; } add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users_by_role' );
你好,请问直接把这段代码贴上去就可以了嘛?需要做什么调整嘛?
我把代码加入到 functions.php,但还是在 members 列表中看到管理员
如果自己是以 「管理员」 账号登录网站的话,还是能看到其他管理员的 (包括自己),是特意设计的,
其他用户是看不到管理员的。
谢谢指教,请问在哪里可以修改用户是否为管理员呢?我创建了一个用户,但似乎在 wp 的用户管理中,没有 bp 的等级设置,只有 bbpress 的等级 (我把这个等级从管理员改为版主,但对于 bp 的用户显示似乎没有改变)
BuddyPress 直接使用 WordPress 的用户等级,也叫 「站点角色」 。
在编辑用户界面中,找到 「姓名」 部分的 「角色」 下拉框,选择 「管理员」,然后保存。
谢谢,在站点角色中,我建立的新用户的角色是编辑,但这个用户登录后,在会员列表中看到管理账号,请问以上的代码需要做什么修改吗?我是直接拷贝到 functions.php 中的。
我在自己的测试站里做了相同的测试,看不到管理员。
(测试站的 BuddyPress 设置里,模板包是 「BuddyPress 旧功能」)
奇怪,我这里总是能看到,会不会和主题的机制有关?
-
作者帖子
正在查看 9 个帖子:1-9 (共 9 个帖子)
- 哎呀,回复话题必需登录。