Ejemplo n.º 1
0
/**
 * Delete a group forum post and its corresponding activity item.
 *
 * Uses the bundled version of bbPress packaged with BuddyPress.
 *
 * @since BuddyPress (1.1.0)
 *
 * @param int      $post_id  The ID of the post you want to delete.
 * @param int|bool $topic_id Optional. The topic to which the post belongs. This
 *                           value isn't used in the function but is passed along
 *                           to do_action() hooks.
 *
 * @return bool True on success.
 */
function groups_delete_group_forum_post($post_id, $topic_id = false)
{
    $action = bp_forums_delete_post(array('post_id' => $post_id));
    if (!empty($action)) {
        /**
         * Fires before the deletion of a group forum post.
         *
         * @since BuddyPress (1.5.0)
         *
         * @param int $post_id  ID of the post to be deleted.
         * @param int $topic_id ID of the associated topic.
         */
        do_action('groups_before_delete_group_forum_post', $post_id, $topic_id);
        // Delete the corresponding activity stream item
        if (bp_is_active('activity')) {
            bp_activity_delete(array('item_id' => bp_get_current_group_id(), 'secondary_item_id' => $post_id, 'component' => buddypress()->groups->id, 'type' => 'new_forum_post'));
        }
        /**
         * Fires after the deletion of a group forum post.
         *
         * @since BuddyPress (1.1.0)
         *
         * @param int $post_id  ID of the post that was deleted.
         * @param int $topic_id ID of the associated topic.
         */
        do_action('groups_delete_group_forum_post', $post_id, $topic_id);
    }
    return (bool) $action;
}
/**
 * Deletes a group forum post and its corresponding activity item.
 *
 * Uses the bundled version of bbPress packaged with BuddyPress.
 *
 * @package BuddyPress
 *
 * @param int $post_id The id of the post you want to delete
 * @param int $topic_id Optional. The topic to which the post belongs. This value isn't used in the
 *   function but is passed along to do_action() hooks.
 * @return bool True on success.
 *
 * @since BuddyPress (1.1)
 */
function groups_delete_group_forum_post($post_id, $topic_id = false)
{
    global $bp;
    if (bp_forums_delete_post(array('post_id' => $post_id))) {
        do_action('groups_before_delete_group_forum_post', $post_id, $topic_id);
        // Delete the corresponding activity stream item
        if (bp_is_active('activity')) {
            bp_activity_delete(array('item_id' => bp_get_current_group_id(), 'secondary_item_id' => $post_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post'));
        }
        do_action('groups_delete_group_forum_post', $post_id, $topic_id);
        return true;
    }
    return false;
}
Ejemplo n.º 3
0
/**
 * Delete a group forum post and its corresponding activity item.
 *
 * Uses the bundled version of bbPress packaged with BuddyPress.
 *
 * @since BuddyPress (1.1.0)
 *
 * @param int $post_id The ID of the post you want to delete.
 * @param int $topic_id Optional. The topic to which the post belongs. This
 *        value isn't used in the function but is passed along to do_action()
 *        hooks.
 * @return bool True on success.
 */
function groups_delete_group_forum_post($post_id, $topic_id = false)
{
    $action = bp_forums_delete_post(array('post_id' => $post_id));
    if (!empty($action)) {
        do_action('groups_before_delete_group_forum_post', $post_id, $topic_id);
        // Delete the corresponding activity stream item
        if (bp_is_active('activity')) {
            bp_activity_delete(array('item_id' => bp_get_current_group_id(), 'secondary_item_id' => $post_id, 'component' => buddypress()->groups->id, 'type' => 'new_forum_post'));
        }
        do_action('groups_delete_group_forum_post', $post_id, $topic_id);
    }
    return (bool) $action;
}
Ejemplo n.º 4
0
function groups_delete_group_forum_post( $post_id, $topic_id ) {
	global $bp;

	if ( bp_forums_delete_post( array( 'post_id' => $post_id ) ) ) {
		/* Delete the activity stream item */
		if ( function_exists( 'bp_activity_delete' ) ) {
			bp_activity_delete( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post' ) );
		}

		do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );

		return true;
	}

	return false;
}