Title: confirm_delete_users
Published: April 25, 2014
Last modified: February 24, 2026

---

# confirm_delete_users( array $users ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#return)
 * [More Information](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#wp--skip-link--target)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#parameters)󠁿

 `$users`arrayrequired

## 󠀁[Return](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#return)󠁿

 bool

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#more-information)󠁿

This function is used to display a confirmation on the Multisite Users administration
panel before deleting users.

Parameter `$users` is An array of IDs of users to delete. Note that this parameter
is currently not used by the function. $_POST['allusers'] is used instead. See [ticket 17905](https://core.trac.wordpress.org/ticket/17905).
Default is none.

       This function returns FALSE if $users is not an array. Otherwise, TRUE.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#source)󠁿

    ```php
    function confirm_delete_users( $users ) {
    	$current_user = wp_get_current_user();
    	if ( ! is_array( $users ) || empty( $users ) ) {
    		return false;
    	}
    	?>
    	<h1><?php esc_html_e( 'Users' ); ?></h1>

    	<?php if ( 1 === count( $users ) ) : ?>
    		<p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
    	<?php else : ?>
    		<p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p>
    	<?php endif; ?>

    	<form action="users.php?action=dodelete" method="post">
    	<input type="hidden" name="dodelete" />
    	<?php
    	wp_nonce_field( 'ms-users-delete' );
    	$site_admins = get_super_admins();
    	$admin_out   = '<option value="' . esc_attr( $current_user->ID ) . '">' . $current_user->user_login . '</option>';
    	?>
    	<table class="form-table" role="presentation">
    	<?php
    	$allusers = (array) $_POST['allusers'];
    	foreach ( $allusers as $user_id ) {
    		if ( '' !== $user_id && '0' !== $user_id ) {
    			$delete_user = get_userdata( $user_id );

    			if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) {
    				wp_die(
    					sprintf(
    						/* translators: %s: User login. */
    						__( 'Warning! User %s cannot be deleted.' ),
    						$delete_user->user_login
    					)
    				);
    			}

    			if ( in_array( $delete_user->user_login, $site_admins, true ) ) {
    				wp_die(
    					sprintf(
    						/* translators: %s: User login. */
    						__( 'Warning! User cannot be deleted. The user %s is a network administrator.' ),
    						'<em>' . $delete_user->user_login . '</em>'
    					)
    				);
    			}
    			?>
    			<tr>
    				<th scope="row"><?php echo $delete_user->user_login; ?>
    					<?php echo '<input type="hidden" name="user[]" value="' . esc_attr( $user_id ) . '" />' . "\n"; ?>
    				</th>
    			<?php
    			$blogs = get_blogs_of_user( $user_id, true );

    			if ( ! empty( $blogs ) ) {
    				?>
    				<td><fieldset><p><legend>
    				<?php
    				printf(
    					/* translators: %s: User login. */
    					__( 'What should be done with content owned by %s?' ),
    					'<em>' . $delete_user->user_login . '</em>'
    				);
    				?>
    				</legend></p>
    				<?php
    				foreach ( (array) $blogs as $key => $details ) {
    					$blog_users = get_users(
    						array(
    							'blog_id' => $details->userblog_id,
    							'fields'  => array( 'ID', 'user_login' ),
    						)
    					);

    					if ( is_array( $blog_users ) && ! empty( $blog_users ) ) {
    						$user_site     = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
    						$user_dropdown = '<label for="reassign_user" class="screen-reader-text">' .
    								/* translators: Hidden accessibility text. */
    								__( 'Select a user' ) .
    							'</label>';
    						$user_dropdown .= "<select name='blog[$user_id][$key]' id='reassign_user'>";
    						$user_list      = '';

    						foreach ( $blog_users as $user ) {
    							if ( ! in_array( (int) $user->ID, $allusers, true ) ) {
    								$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
    							}
    						}

    						if ( '' === $user_list ) {
    							$user_list = $admin_out;
    						}

    						$user_dropdown .= $user_list;
    						$user_dropdown .= "</select>\n";
    						?>
    						<ul style="list-style:none;">
    							<li>
    								<?php
    								/* translators: %s: Link to user's site. */
    								printf( __( 'Site: %s' ), $user_site );
    								?>
    							</li>
    							<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID; ?>]" value="delete" checked="checked" />
    							<?php _e( 'Delete all content.' ); ?></label></li>
    							<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID; ?>]" value="reassign" />
    							<?php _e( 'Attribute all content to:' ); ?></label>
    							<?php echo $user_dropdown; ?></li>
    						</ul>
    						<?php
    					}
    				}
    				echo '</fieldset></td></tr>';
    			} else {
    				?>
    				<td><p><?php _e( 'User has no sites or content and will be deleted.' ); ?></p></td>
    			<?php } ?>
    			</tr>
    			<?php
    		}
    	}

    	?>
    	</table>
    	<?php
    	/** This action is documented in wp-admin/users.php */
    	do_action( 'delete_user_form', $current_user, $allusers );

    	if ( 1 === count( $users ) ) :
    		?>
    		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
    	<?php else : ?>
    		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.' ); ?></p>
    		<?php
    	endif;

    	submit_button( __( 'Confirm Deletion' ), 'primary' );
    	?>
    	</form>
    	<?php
    	return true;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/ms.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/ms.php#L862)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/ms.php#L862-L1004)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#hooks)󠁿

 [do_action( ‘delete_user_form’, WP_User $current_user, int[] $user_ids )](https://developer.wordpress.org/reference/hooks/delete_user_form/)

Fires at the end of the delete users form prior to the confirm button.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#related)󠁿

| Uses | Description | 
| [submit_button()](https://developer.wordpress.org/reference/functions/submit_button/)`wp-admin/includes/template.php` |

Echoes a submit button, with provided text and appropriate class(es).

  | 
| [get_super_admins()](https://developer.wordpress.org/reference/functions/get_super_admins/)`wp-includes/capabilities.php` |

Retrieves a list of super admins.

  | 
| [esc_html_e()](https://developer.wordpress.org/reference/functions/esc_html_e/)`wp-includes/l10n.php` |

Displays translated text that has been escaped for safe use in HTML output.

  | 
| [wp_get_current_user()](https://developer.wordpress.org/reference/functions/wp_get_current_user/)`wp-includes/pluggable.php` |

Retrieves the current user object.

  | 
| [wp_nonce_field()](https://developer.wordpress.org/reference/functions/wp_nonce_field/)`wp-includes/functions.php` |

Retrieves or display nonce hidden field for forms.

  | 
| [get_home_url()](https://developer.wordpress.org/reference/functions/get_home_url/)`wp-includes/link-template.php` |

Retrieves the URL for a given site where the front end is accessible.

  | 
| [get_blogs_of_user()](https://developer.wordpress.org/reference/functions/get_blogs_of_user/)`wp-includes/user.php` |

Gets the sites a user belongs to.

  | 
| [get_users()](https://developer.wordpress.org/reference/functions/get_users/)`wp-includes/user.php` |

Retrieves list of users matching criteria.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [_e()](https://developer.wordpress.org/reference/functions/_e/)`wp-includes/l10n.php` |

Displays translated text.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_attr()](https://developer.wordpress.org/reference/functions/esc_attr/)`wp-includes/formatting.php` |

Escaping for HTML attributes.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [get_userdata()](https://developer.wordpress.org/reference/functions/get_userdata/)`wp-includes/pluggable.php` |

Retrieves user info by user ID.

  | 
| [wp_die()](https://developer.wordpress.org/reference/functions/wp_die/)`wp-includes/functions.php` |

Kills WordPress execution and displays HTML page with an error message.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  |

[Show 11 more](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#comment-content-3861)
 2.    [MakeWebBetter](https://profiles.wordpress.org/makewebbetter/)  [  6 years ago  ](https://developer.wordpress.org/reference/functions/confirm_delete_users/#comment-3861)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fconfirm_delete_users%2F%23comment-3861)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fconfirm_delete_users%2F%23comment-3861)
 4.  **Delete users who hold subscriber role**
 5.      ```php
         <?php
         $args = array(
             'role' => 'subscriber',
             'field' => 'ID'
         );
         $args = array( 'role' => 'subscriber' );
         $subscribers = get_users( $args );
         $subscriber_role_ids = array(); 
         foreach ( $subscribers as $user ) {
             $subscriber_role_ids[] = $user->ID;
         }
         confirm_delete_users( $subscriber_role_ids );
         ?>
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fconfirm_delete_users%2F%3Freplytocom%3D3861%23feedback-editor-3861)
 7.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/confirm_delete_users/?output_format=md#comment-content-1547)
 8.    [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/confirm_delete_users/#comment-1547)
 9.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fconfirm_delete_users%2F%23comment-1547)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fconfirm_delete_users%2F%23comment-1547)
 10. **Example**
 11.     ```php
         <?php confirm_delete_users( array( 1, 3, 45, 7, 378, ) ); ?>
         ```
     
 12.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fconfirm_delete_users%2F%3Freplytocom%3D1547%23feedback-editor-1547)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fconfirm_delete_users%2F)
before being able to contribute a note or feedback.