本文整理汇总了PHP中BP_Groups_Member::ban方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Groups_Member::ban方法的具体用法?PHP BP_Groups_Member::ban怎么用?PHP BP_Groups_Member::ban使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BP_Groups_Member
的用法示例。
在下文中一共展示了BP_Groups_Member::ban方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_group_management_ban_member
function bp_group_management_ban_member($user_id, $group_id)
{
global $bp;
$member = new BP_Groups_Member($user_id, $group_id);
do_action('groups_ban_member', $group_id, $user_id);
if (!$member->ban()) {
return false;
}
update_usermeta($user_id, 'total_group_count', (int) $total_count - 1);
return true;
}
示例2: test_get_is_banned_of_with_filter
public function test_get_is_banned_of_with_filter()
{
$g1 = $this->factory->group->create(array('name' => 'RC Cola'));
$g2 = $this->factory->group->create(array('name' => 'Pepsi'));
$u = $this->factory->user->create();
self::add_user_to_group($u, $g1);
self::add_user_to_group($u, $g2);
$m1 = new BP_Groups_Member($u, $g1);
$m1->ban();
$m2 = new BP_Groups_Member($u, $g2);
$m2->ban();
$groups = BP_Groups_Member::get_is_banned_of($u, false, false, 'eps');
$ids = wp_list_pluck($groups['groups'], 'id');
$this->assertEquals($ids, array($g2));
}
示例3: groups_ban_member
/**
* Ban a member from a group.
*
* @param int $user_id ID of the user.
* @param int $group_id ID of the group.
*
* @return bool True on success, false on failure.
*/
function groups_ban_member($user_id, $group_id)
{
if (!bp_is_item_admin()) {
return false;
}
$member = new BP_Groups_Member($user_id, $group_id);
/**
* Fires before the banning of a member from a group.
*
* @since 1.0.0
*
* @param int $group_id ID of the group being banned from.
* @param int $user_id ID of the user being banned.
*/
do_action('groups_ban_member', $group_id, $user_id);
return $member->ban();
}
示例4: test_groups_is_user_banned_should_return_true_for_banned_member
public function test_groups_is_user_banned_should_return_true_for_banned_member()
{
$this->add_user_to_group(self::$user, self::$groups[1]);
$m = new BP_Groups_Member(self::$user, self::$groups[1]);
$m->ban();
$this->assertNotEmpty(groups_is_user_banned(self::$user, self::$groups[1]));
}
示例5: groups_ban_member
function groups_ban_member($user_id, $group_id)
{
if (!bp_is_item_admin()) {
return false;
}
$member = new BP_Groups_Member($user_id, $group_id);
do_action('groups_ban_member', $group_id, $user_id);
return $member->ban();
}
示例6: test_with_group_role_banned
/**
* @group role
*/
public function test_with_group_role_banned()
{
$g = $this->factory->group->create();
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
$time = time();
$this->add_user_to_group($u1, $g, array('date_modified' => gmdate('Y-m-d H:i:s', $time - 100)));
$this->add_user_to_group($u2, $g, array('date_modified' => gmdate('Y-m-d H:i:s', $time - 200)));
$m1 = new BP_Groups_Member($u1, $g);
$m1->ban();
$query_members = new BP_Group_Member_Query(array('group_id' => $g, 'group_role' => array('banned')));
$ids = wp_parse_id_list(array_keys($query_members->results));
$this->assertEquals(array($u1), $ids);
}
示例7: groups_ban_member
function groups_ban_member($user_id, $group_id)
{
global $bp;
if (!$bp->is_item_admin) {
return false;
}
$member = new BP_Groups_Member($user_id, $group_id);
do_action('groups_ban_member', $group_id, $user_id);
return $member->ban();
}
示例8: groups_ban_member
function groups_ban_member($user_id, $group_id)
{
global $bp;
/* Check the nonce first. */
if (!check_admin_referer('groups_ban_member')) {
return false;
}
if (!$bp->is_item_admin) {
return false;
}
$member = new BP_Groups_Member($user_id, $group_id);
do_action('groups_ban_member', $user_id, $group_id);
return $member->ban();
}
示例9: test_cache_should_be_invalidated_on_group_unban
/**
* @group cache
*/
public function test_cache_should_be_invalidated_on_group_unban()
{
$m1 = new BP_Groups_Member(self::$user, self::$groups[1]);
$m1->ban();
// Populate cache.
$g1 = bp_get_user_groups(self::$user);
$m2 = new BP_Groups_Member(self::$user, self::$groups[1]);
$m2->unban();
$expected = array(self::$groups[0], self::$groups[1]);
$found = bp_get_user_groups(self::$user);
$this->assertEqualSets($expected, array_keys($found));
}
示例10: test_bp_group_has_members_with_exclude_banned_0
/**
* @group bp_group_has_members
*/
public function test_bp_group_has_members_with_exclude_banned_0()
{
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
$u3 = $this->factory->user->create();
$g = $this->factory->group->create(array('creator_id' => $u1));
$now = time();
$this->add_user_to_group($u2, $g, array('date_modified' => gmdate('Y-m-d H:i:s', $now - 60 * 60 * 24)));
$this->add_user_to_group($u3, $g, array('date_modified' => gmdate('Y-m-d H:i:s', $now - 60 * 60 * 12)));
$m2 = new BP_Groups_Member($u2, $g);
$m2->ban();
global $members_template;
bp_group_has_members(array('group_id' => $g, 'exclude_banned' => 0, 'exclude_admins_mods' => false));
$ids = wp_parse_id_list(wp_list_pluck($members_template->members, 'user_id'));
$this->assertEquals(array($u1, $u3, $u2), $ids);
}