confirm_delete_users( array $users ): bool
- Since
- 3.0.0
- Source
wp-admin/includes/ms.php:862
Compatibility
- WordPress
- since 3.0.0
- 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
- Scaling
- Scales with input
- Instructions
- 7–70
- Plugin surface
- 1 hook
- Called by
- 0
Reaches the database via get_users().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 261.
Third-party callbacks on 'delete_user_form' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- querycontent query
get_users()called directly - hookthird-party callbacks
do_action()called directly - optionnetwork option
get_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.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 7–9 | wp_get_current_user() |
is_array($users) && !empty($users) | 67–70 | wp_get_current_user(), esc_html_e(), _e(), wp_nonce_field(), get_super_admins(), esc_attr(), do_action(), _e(), __(), submit_button() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 261 | 7–70 | 19 | |
| 8.5 | 261 | 7–70 | 19 | |
| 8.4 | 261 | 7–70 | 19 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 267 | 7–70 | 19 | |
| 8.2 | 267 | 7–70 | 19 | |
| 8.1 | 267 | 7–70 | 19 | |
| 7.4 | 267 | 7–70 | 19 |
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:
- do_action( delete_user_form )actionline 989 (+127 into the body)
Fires at the end of the delete users form prior to the confirm button.
Uses · 16
- wp_get_current_user()Retrieves the current user object.
- esc_html_e()Displays translated text that has been escaped for safe use in HTML output.
- _e()Displays translated text.
- wp_nonce_field()Retrieves or display nonce hidden field for forms.
- get_super_admins()Retrieves a list of super admins.
- esc_attr()Escaping for HTML attributes.
- get_userdata()Retrieves user info by user ID.
- current_user_can()Returns whether the current user has the specified capability.
- wp_die()Kills WordPress execution and displays HTML page with an error message.
- __()Retrieves the translation of $text.
- get_blogs_of_user()Gets the sites a user belongs to.
- get_users()Retrieves list of users matching criteria.
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
Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.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.