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 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.

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

No Hooks.

Return

WP_User. Current WP_User instance.

Usage

wp_get_current_user();

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

<?php
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