confirm_delete_users( array $users ): bool
- Since
- 3.0.0
- Source
wp-admin/includes/ms.php:858
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
- 8–61
- Plugin surface
- 2 hooks
- 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 371.
Third-party callbacks on 'users_have_additional_content', '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
apply_filters()called directly - optionnetwork option
get_site_option()one call below confirm_delete_users() - cacheobject cache
wp_cache_switch_to_blog()one call below confirm_delete_users()
Further down the call graph this can also reach 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 | 8–10 | wp_get_current_user() |
is_array($users) && !empty($users) | 58–61 | wp_get_current_user(), esc_html_e(), _e(), wp_nonce_field(), get_super_admins(), do_action(), _e(), __(), submit_button() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 371 | 8–61 | 19 | |
| 8.5 | 371 | 8–61 | 19 | |
| 8.4 | 371 | 8–61 | 19 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 374 | 8–61 | 19 | |
| 8.2 | 374 | 8–61 | 19 | |
| 8.1 | 374 | 8–61 | 19 | |
| 7.4 | 374 | 8–61 | 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 · 2
2 hooks fire while confirm_delete_users() runs, in this order:
- apply_filters( users_have_additional_content )filterline 943 (+85 into the body)
Filters whether the users being deleted have additional content associated with them outside of the `post_author` and `link_owner` relationships.
- do_action( delete_user_form )actionline 1031 (+173 into the body)
Fires at the end of the delete users form prior to the confirm button.
Uses · 21
- 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.
- 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.
- esc_attr()Escaping for HTML attributes.
- get_blogs_of_user()Gets the sites a user belongs to.
- get_users()Retrieves list of users matching criteria.
Show all 21
- wp_list_pluck()Plucks a certain field out of each object or array in an array.
- esc_url()Checks and cleans a URL.
- get_home_url()Retrieves the URL for a given site where the front end is accessible.
- switch_to_blog()Switches the current blog.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- restore_current_blog()Restores the current blog, after calling switch_to_blog().
- wp_dropdown_users()Creates dropdown HTML content of users.
- 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 ) { global $wpdb; $current_user = wp_get_current_user(); if ( ! is_array( $users ) || empty( $users ) ) { return false; } ?> <h1><?php esc_html_e( 'Delete 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" class="delete-and-reassign-users-form"> <input type="hidden" name="dodelete" /> <?php wp_nonce_field( 'ms-users-delete' ); $site_admins = get_super_admins(); ?> <table class="form-table" role="presentation"> <?php foreach ( $users 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><legend> <?php printf( /* translators: 1: User login, 2: User ID. */ __( '%1$s (ID #%2$s): What should be done with the content owned by this user?' ), '<strong>' . $delete_user->user_login . '</strong>', $user_id ); ?> </legend> <?php foreach ( (array) $blogs as $key => $details ) { $blog_users = get_users( array( 'blog_id' => $details->userblog_id, 'fields' => array( 'ID' ), 'exclude' => $users, ) ); $blog_users = wp_list_pluck( $blog_users, 'ID' );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 7.1.0 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.