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
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
| 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.