update_user_status( int $id, string $pref, int $value, null $deprecated = null ): int
- Since
- 3.0.0
- Source
wp-includes/ms-deprecated.php:709
Description
Previously used in core to mark a user as spam or "ham" (not spam) in Multisite.
Compatibility
Deprecated in WordPress 5.3.0. Use wp_update_user()
- 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
$idint- The user ID.
$prefstring- The column in the wp_users table to update the user's status in (presumably user_status, spam, or deleted).
$valueint- The new status for the user.
$deprecatednulloptional- Deprecated as of 3.0.2 and should not be used.Default:
null
Return value
int- The initially passed $value.
Performance profile
How much work a call to update_user_status() 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
- Light
- Scaling
- Constant
- Instructions
- 34–44
- Plugin surface
- 2 hooks
- Called by
- 0
Only touches the object cache, via wp_cache_delete().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 49.
Third-party callbacks on 'make_spam_user', 'make_ham_user' 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
- hookthird-party callbacks
do_action()called directly - cacheobject cache
wp_cache_delete()one call below update_user_status()
Further down the call graph this can also reach query, option, 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 · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost update_user_status() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$deprecated === null && $pref !== "spam" | 34 | _deprecated_function(), sanitize_key(), ID(), clean_user_cache() |
$deprecated !== null && $pref !== "spam" | 38 | _deprecated_function(), _deprecated_argument(), sanitize_key(), ID(), clean_user_cache() |
$deprecated === null && $pref === "spam" | 40 | _deprecated_function(), sanitize_key(), ID(), clean_user_cache(), do_action() |
$deprecated !== null && $pref === "spam" | 44 | _deprecated_function(), _deprecated_argument(), sanitize_key(), ID(), clean_user_cache(), do_action() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 49 instructions, 34–44 executed per call, 3 branches. The work does not change between versions.
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 update_user_status() runs, in this order:
- do_action( make_spam_user )actionline 726 (+17 into the body)
Fires after the user is marked as a SPAM user.
- do_action( make_ham_user )actionline 729 (+20 into the body)
Fires after the user is marked as a HAM user. Opposite of SPAM.
Uses · 6
- _deprecated_function()Marks a function as deprecated and inform when it has been used.
- _deprecated_argument()Marks a function argument as deprecated and inform when it has been used.
- sanitize_key()Sanitizes a string key.
- clean_user_cache()Cleans all user caches.
- do_action()Calls the callback functions that have been added to an action hook.
- WP_User::__construct()Constructor.
Source code
function update_user_status( $id, $pref, $value, $deprecated = null ) { global $wpdb; _deprecated_function( __FUNCTION__, '5.3.0', 'wp_update_user()' ); if ( null !== $deprecated ) { _deprecated_argument( __FUNCTION__, '3.0.2' ); } $wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) ); $user = new WP_User( $id ); clean_user_cache( $user ); if ( 'spam' === $pref ) { if ( $value == 1 ) { /** This filter is documented in wp-includes/user.php */ do_action( 'make_spam_user', $id ); } else { /** This filter is documented in wp-includes/user.php */ do_action( 'make_ham_user', $id ); } } return $value;}Changelog
Introduced in 3.0.0. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$deprecated retyped from null to mixed.verified against sourceAbout this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/ms-deprecated.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.