コード例 #1
0
 /**
  * @covers ::bbp_remove_user_from_object
  */
 public function test_bbp_remove_user_from_object()
 {
     $u = $this->factory->user->create();
     $t = $this->factory->topic->create();
     // Add object terms.
     add_metadata('post', $t, '_bbp_moderator', $u, false);
     $r = get_metadata('post', $t, '_bbp_moderator', false);
     $this->assertCount(1, $r);
     $r = bbp_remove_user_from_object($t, $u, '_bbp_moderator');
     $this->assertTrue($r);
     $r = get_metadata('post', $t, '_bbp_moderator', false);
     $this->assertCount(0, $r);
 }
コード例 #2
0
/**
 * Remove a user subscription
 *
 * @since 2.0.0 bbPress (r2668)
 *
 * @param int $user_id Optional. User id
 * @param int $object_id Optional. Topic id
 * @uses get_post() To get the post object
 * @uses bbp_is_user_subscribed() To check if the user is already subscribed
 * @uses do_action() Calls 'bbp_remove_user_subscription' with the user id and
 *                    topic id
 * @return bool True if the topic was removed from user's subscriptions,
 *               otherwise false
 */
function bbp_remove_user_subscription($user_id = 0, $object_id = 0)
{
    // Bail if not enough info
    if (empty($user_id) || empty($object_id)) {
        return false;
    }
    // Get post type
    $post_type = get_post_type($object_id);
    if (empty($post_type)) {
        return false;
    }
    // Bail if not subscribed
    if (!bbp_is_user_subscribed($user_id, $object_id)) {
        return false;
    }
    // Bail if remove fails
    if (!bbp_remove_user_from_object($object_id, $user_id, '_bbp_subscription')) {
        return false;
    }
    do_action('bbp_remove_user_subscription', $user_id, $object_id, $post_type);
    return true;
}
コード例 #3
0
/**
 * Remove a moderator user ID from an object
 *
 * @since 2.6.0 bbPress
 *
 * @param int $object_id
 * @param int $user_id
 *
 * @return bool
 */
function bbp_remove_moderator($object_id = 0, $user_id = 0)
{
    return bbp_remove_user_from_object($object_id, $user_id, '_bbp_moderator_id');
}