WordPress at a glance

wp_get_current_user() WP 1.0

Retrieve the current user object.

Will set the current user, if the current user is not set. The current user will be set to the logged-in person. If no user is logged-in, then it will set the current user to 0, which is invalid and won't have any permissions.

  • See: _wp_get_current_user()
  • Global. WP_User. $current_user Checks if the current user is set.

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

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

✈ 1 time = 0.00001s = speed of light | 50000 times = 0.03s = speed of light

No Hooks.


WP_User. Current WP_User instance.



Code of wp_get_current_user: wp-includes/pluggable.php VER 5.0.1

function wp_get_current_user() {
	return _wp_get_current_user();

Related Functions

From tag: Users (_user)

More from category: Other

No comments
    Hello, !     Log In . Register