コード例 #1
0
/**
 * xprofile_action_delete_wire_post()
 *
 * Deletes a wire post from the users profile wire. 
 * 
 * @package BuddyPress XProfile
 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
 * @uses bp_wire_delete_post() Deletes a wire post for a specific wire using the ID of the item passed and the table name.
 * @uses xprofile_delete_activity() Deletes an activity item for the xprofile component and a particular user.
 * @uses bp_core_add_message() Adds an error/success message to the session to be displayed on the next page load.
 * @uses bp_core_redirect() Safe redirects to a new page using the wp_redirect() function
 */
function xprofile_action_delete_wire_post()
{
    global $bp;
    if ($bp->current_component != $bp->wire->slug) {
        return false;
    }
    if ($bp->current_action != 'delete') {
        return false;
    }
    if (!check_admin_referer('bp_wire_delete_link')) {
        return false;
    }
    $wire_post_id = $bp->action_variables[0];
    if (bp_wire_delete_post($wire_post_id, $bp->profile->slug, $bp->profile->table_name_wire)) {
        bp_core_add_message(__('Wire message successfully deleted.', 'buddypress'));
        do_action('xprofile_delete_wire_post', $wire_post_id);
    } else {
        bp_core_add_message(__('Wire post could not be deleted, please try again.', 'buddypress'), 'error');
    }
    if (!strpos($_SERVER['HTTP_REFERER'], $bp->wire->slug)) {
        bp_core_redirect($bp->displayed_user->domain);
    } else {
        bp_core_redirect($bp->displayed_user->domain . $bp->wire->slug);
    }
}
コード例 #2
0
ファイル: bp-groups.php プロジェクト: alvaropereyra/shrekcms
function groups_delete_wire_post($wire_post_id, $table_name)
{
    global $bp;
    /* Check the nonce first. */
    if (!check_admin_referer('bp_wire_delete_link')) {
        return false;
    }
    if (bp_wire_delete_post($wire_post_id, $bp->groups->slug, $table_name)) {
        do_action('groups_deleted_wire_post', $wire_post_id);
        return true;
    }
    return false;
}