wp_get_current_user() WordPress Function

The wp_get_current_user() function is used to get the current user object. This function will return an object of the current user, if the user is logged in. If the user is not logged in, then this function will return a WP_Error object.

wp_get_current_user() #

Retrieve the current user object.


Description

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.

Top ↑

See also


Top ↑

Return

(WP_User) Current WP_User instance.


Top ↑

Source

File: wp-includes/pluggable.php

	function wp_get_current_user() {
		return _wp_get_current_user();
	}


Top ↑

Changelog

Changelog
VersionDescription
2.0.3Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More