WP_User
- Since
- 2.0.0, 6.8.0
- Source
wp-includes/class-wp-user.php:41
Core class used to implement the WP_User object.
Hooks fired · 6
Every hook that fires from inside WP_User, in the order it appears in the class, grouped by the method that fires it.
WP_User::add_role()
- do_action( add_user_role )action line 575
WP_User::remove_role()
- do_action( remove_user_role )action line 603
WP_User::set_role()
- do_action( remove_user_role )action line 645
- do_action( add_user_role )action line 650
- do_action( set_user_role )action line 663
WP_User::has_cap()
- apply_filters( user_has_cap )filter line 821
Properties · 9
$datastdClasspublic- User data container.
$IDintpublic- The user's ID.
$capsbool[]public- Capabilities that the individual user has been granted outside of those inherited from their role.
$cap_keystringpublic- User metadata option name.
$rolesstring[]public- The roles the user is part of.
$allcapsbool[]public- All capabilities the user has, including individual and role based.
$filterstringpublic- The filter context applied to user data fields.
$site_idintprivate- The site ID the capabilities of this user are initialized for.
$back_compat_keysarrayprivate static
Methods · 28
- __construct()Constructor.
- init()Sets up object properties, including capabilities.
- get_data_by()Returns only the main user fields.
- __isset()Magic method for checking the existence of a certain custom field.
- __get()Magic method for accessing custom fields.
- __set()Magic method for setting custom user fields.
- __unset()Magic method for unsetting a certain custom field.
- exists()Determines whether the user exists in the database.
- get()Retrieves the value of a property or meta key.
- has_prop()Determines whether a property or meta key is set.
- to_array()Returns an array representation.
- __call()Makes private/protected methods readable for backward compatibility.
- _init_caps()Sets up capability object properties.
- get_role_caps()Retrieves all of the capabilities of the user's roles, and merges them with individual user capabilities.
- add_role()Adds role to user.
- remove_role()Removes role from user.
- set_role()Sets the role of the user.
- level_reduction()Chooses the maximum level the user has.
- update_user_level_from_caps()Updates the maximum user level for the user.
- add_cap()Adds capability and grant or deny access to capability.
- remove_cap()Removes capability from user.
- remove_all_caps()Removes all of the capabilities of the user.
- has_cap()Returns whether the user has the specified capability.
- translate_level_to_cap()Converts numeric level to level capability name.
- for_blog()Sets the site to operate on. Defaults to the current site.
- for_site()Sets the site to operate on. Defaults to the current site.
- get_site_id()Gets the ID of the site for which the user's capabilities are currently initialized.
- get_caps_data()Gets the available user capabilities data.
Source
#[AllowDynamicProperties]class WP_User { /** * User data container. * * @since 2.0.0 * @var stdClass */ public $data; /** * The user's ID. * * @since 2.1.0 * @var int */ public $ID = 0; /** * Capabilities that the individual user has been granted outside of those inherited from their role. * * @since 2.0.0 * @var bool[] Array of key/value pairs where keys represent a capability name * and boolean values represent whether the user has that capability. */ public $caps = array(); /** * User metadata option name. * * @since 2.0.0 * @var string */ public $cap_key; /** * The roles the user is part of. * * @since 2.0.0 * @var string[] */ public $roles = array(); /** * All capabilities the user has, including individual and role based. * * @since 2.0.0 * @var bool[] Array of key/value pairs where keys represent a capability name * and boolean values represent whether the user has that capability. */ public $allcaps = array(); /** * The filter context applied to user data fields. * * @since 2.9.0 * @var string */ public $filter = null; /** * The site ID the capabilities of this user are initialized for. * * @since 4.9.0 * @var int */ private $site_id = 0; /** * @since 3.3.0 * @var array */ private static $back_compat_keys; /** * Constructor. * * Retrieves the userdata and passes it to WP_User::init(). * * @since 2.0.0History
Introduced in 2.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
6.8.0
The
user_pass property is now hashed using bcrypt by default instead of phpass. Existing passwords may still be hashed using phpass.from the docblock2.0.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/class-wp-user.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.