bp_groups_admin_delete()

Display the Group delete confirmation screen.

Description

We include a separate confirmation because group deletion is truly irreversible.

Source

File: bp-groups/bp-groups-admin.php

984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
function bp_groups_admin_delete() {
 
    if ( ! bp_current_user_can( 'bp_moderate' ) ) {
        die( '-1' );
    }
 
    $group_ids = isset( $_REQUEST['gid'] ) ? $_REQUEST['gid'] : 0;
    if ( ! is_array( $group_ids ) ) {
        $group_ids = explode( ',', $group_ids );
    }
    $group_ids = wp_parse_id_list( $group_ids );
    $groups    = groups_get_groups( array(
        'include'     => $group_ids,
        'show_hidden' => true,
        'per_page'    => null, // Return all results.
    ) );
 
    // Create a new list of group ids, based on those that actually exist.
    $gids = array();
    foreach ( $groups['groups'] as $group ) {
        $gids[] = $group->id;
    }
 
    $base_url  = remove_query_arg( array( 'action', 'action2', 'paged', 's', '_wpnonce', 'gid' ), $_SERVER['REQUEST_URI'] ); ?>
 
    <div class="wrap">
        <h1><?php _e( 'Delete Groups', 'buddyboss' ) ?></h1>
        <p><?php _e( 'You are about to delete the following groups:', 'buddyboss' ) ?></p>
 
        <ul class="bp-group-delete-list">
        <?php foreach ( $groups['groups'] as $group ) : ?>
            <li>
                <?php echo esc_html( bp_get_group_name( $group ) ); ?>
                <?php if (  bp_is_active('forums') && bbp_get_group_forum_ids( $group->id ) ): ?>
                    <label for="delete-group-forum-<?php echo $group->id ?>" class="delete-forum-label">
                        <input type="checkbox" name="delete_group_forum" id="delete-group-forum-<?php echo $group->id ?>" value="<?php echo $group->id ?>" checked/>
                        <?php esc_html_e( 'Permanently delete the group discussion forum', 'buddyboss' ); ?>
                    </label>
                <?php endif; ?>
            </li>
        <?php endforeach; ?>
        </ul>
 
        <p><strong><?php _e( 'This action cannot be undone.', 'buddyboss' ) ?></strong></p>
 
        <a
            class="button-primary"
            id="delete-groups-submit"
            href="<?php echo esc_url( wp_nonce_url( add_query_arg( array(
                'action' => 'do_delete',
                'gid'    => implode( ',', $gids )
            ), $base_url ), 'bp-groups-delete' ) ); ?>"
        >
            <?php _e( 'Delete Permanently', 'buddyboss' ) ?>
        </a>
        <a class="button" href="<?php echo esc_attr( $base_url ); ?>"><?php _e( 'Cancel', 'buddyboss' ) ?></a>
    </div>
 
    <?php
}

Changelog

Changelog
Version Description
BuddyPress 1.7.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.