Users: Add `get_user()` alias.

Add `get_user()` as an alias for `get_user_by( 'id', $user_id )`. Add `get_user()` to `user.php` so it is not a pluggable function. Bring parity with other standard `get_` functions for a more intuitive developer experience.

Props sc0ttkclark, kushang78, joedolson, peterwilsoncc.
Fixes #35124.
Built from https://develop.svn.wordpress.org/trunk@59111


git-svn-id: http://core.svn.wordpress.org/trunk@58507 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2024-09-28 23:08:18 +00:00
parent cfc609eb3e
commit dfa14f95bb
2 changed files with 14 additions and 1 deletions

View File

@ -775,6 +775,19 @@ function delete_user_option( $user_id, $option_name, $is_global = false ) {
return delete_user_meta( $user_id, $option_name ); return delete_user_meta( $user_id, $option_name );
} }
/**
* Retrieves user info by user ID.
*
* @since 6.7
*
* @param int $user_id User ID.
*
* @return WP_User|false WP_User object on success, false on failure.
*/
function get_user( $user_id ) {
return get_user_by( 'id', $user_id );
}
/** /**
* Retrieves list of users matching criteria. * Retrieves list of users matching criteria.
* *

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.7-alpha-59110'; $wp_version = '6.7-alpha-59111';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.