wppaste
WordPress

confirm_delete_users( array $users ): bool

Source
wp-admin/includes/ms.php:860

Compatibility

WordPress
core
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$usersarray

Return value

bool

Performance profile

How much work a call to confirm_delete_users() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reaches the database via get_users().

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
7–70

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 261.

Plugin surface
1 hook

Third-party callbacks on 'delete_user_form' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • querycontent queryget_users()called directly
  • hookthird-party callbacksdo_action()called directly
  • optionnetwork optionget_site_option()one call below confirm_delete_users()

Further down the call graph this can also reach cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 2 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost confirm_delete_users() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always7–9wp_get_current_user()
is_array($users) && !empty($users)67–70wp_get_current_user(), esc_html_e(), _e(), wp_nonce_field(), get_super_admins(), esc_attr(), do_action(), _e(), __(), submit_button()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev2617–7019
8.52617–7019
8.42617–70196 fewer instructions than PHP 8.3
8.32677–7019
8.22677–7019
8.12677–7019
7.42677–7019

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

One hook fires while confirm_delete_users() runs, in this order:

  1. do_action( delete_user_form )actionline 987 (+127 into the body)

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

Uses · 16

Show all 16
  • esc_url()Checks and cleans a URL.
  • get_home_url()Retrieves the URL for a given site where the front end is accessible.
  • do_action()Calls the callback functions that have been added to an action hook.
  • submit_button()Echoes a submit button, with provided text and appropriate class(es).

Source code

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

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-admin/includes/ms.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.