WordPress at a glance

get_userdata() WP 1.0

Retrieve user info by user ID.

This is a pluggable function, and it can be replaced by a plugin. It means that this function is defined (works) only after all plugins are loaded (included), but before this moment this function has not defined. Therefore, you cannot call this and all functions depended on this function directly from a plugin code. It must be called on plugins_loaded hook or later, for example on init hook.

Function replacement (override) — in a plugin you can create a function with the same name, then it replace this function.

Works based on: get_user_by()
✈ 1 time = 0.000296s = fast | 50000 times = 0.78s = very fast | PHP 7.1.2RC1, WP 4.7.2

No Hooks.

Return

WP_User/false. WP_User object on success, false on failure.

Usage

get_userdata( $user_id );
$user_id(int) (required)
User ID

Code of get userdata: wp-includes/pluggable.php WP 5.2.1

<?php
function get_userdata( $user_id ) {
	return get_user_by( 'id', $user_id );
}

Related Functions

From tag: Users (_user)

More from category: Other

No comments
    Hello, !     Log In . Register