ClarksonCore

Clarkson_User
in package

Object oriented wrapper for WP_User objects.

Table of Contents

__construct()  : mixed
Clarkson_User constructor.
add_meta()  : int|false
Add a meta key=>value for the user.
current_user()  : Clarkson_User|null
Get the current logged in user.
delete_meta()  : bool
Delete a meta key=>value for the user.
get()  : Clarkson_User|null
Get user data by user id.
get_display_first_name()  : string
Get the user's first name.
get_display_last_name()  : string
Get the user's last name.
get_display_name()  : string
Get the display name of the user.
get_email()  : string
Get the user's email address.
get_id()  : int
Get the ID of the user.
get_login()  : string
Get the user's login name.
get_many()  : array<string|int, Clarkson_User>
Get multiple users as Clarkson users.
get_meta()  : array<string|int, mixed>|string
Get the user's user_meta data.
get_one()  : Clarkson_User|null
Gets the first result from a `::get_many()` query.
get_role_objects()  : array<string|int, Clarkson_Role>
Get the user's role objects.
get_roles()  : array<string|int, string>
Get the user's roles.
get_user()  : WP_User
Get the WordPress WP_User object.
is_current_user()  : bool
Check if this user is the currently logged in user.
update_meta()  : bool|int
Update user meta data.

Methods

__construct()

Clarkson_User constructor.

public __construct(WP_User $user) : mixed
Parameters
$user : WP_User
Return values
mixed

add_meta()

Add a meta key=>value for the user.

public add_meta(string $key, array<string|int, mixed>|string $value) : int|false

See: https://github.com/level-level/Clarkson-Core/issues/124.

Parameters
$key : string

User meta key.

$value : array<string|int, mixed>|string

User meta data.

Return values
int|false

delete_meta()

Delete a meta key=>value for the user.

public delete_meta(string $key[, array<string|int, mixed>|string $value = '' ]) : bool

See: https://github.com/level-level/Clarkson-Core/issues/124.

Parameters
$key : string

User meta key.

$value : array<string|int, mixed>|string = ''

User meta data.

Return values
bool

get_display_first_name()

Get the user's first name.

public get_display_first_name() : string
Return values
string

User first name.

get_display_last_name()

Get the user's last name.

public get_display_last_name() : string
Return values
string

User last name.

get_display_name()

Get the display name of the user.

public get_display_name() : string
Return values
string

User display name.

get_email()

Get the user's email address.

public get_email() : string
Return values
string

Email address.

get_id()

Get the ID of the user.

public get_id() : int
Return values
int

User id.

get_login()

Get the user's login name.

public get_login() : string
Return values
string

Login name.

get_many()

Get multiple users as Clarkson users.

public static get_many(array<string|int, mixed> $args[, mixed &$user_query = null ]) : array<string|int, Clarkson_User>
Parameters
$args : array<string|int, mixed>

User query arguments.

$user_query : mixed = null

The $user_query is passed by reference and will be filled with the WP_User_Query that produced these results.

Tags
example

\Clarkson_User::get_many( array( 'role' => 'subscriber' ), $user_query );

Return values
array<string|int, Clarkson_User>

get_meta()

Get the user's user_meta data.

public get_meta([string $key = '' ][, bool $single = false ]) : array<string|int, mixed>|string

See: https://github.com/level-level/Clarkson-Core/issues/124.

Parameters
$key : string = ''

Meta key.

$single : bool = false

If true return value of meta data field, if false return an array.

Return values
array<string|int, mixed>|string

Meta data.

get_one()

Gets the first result from a `::get_many()` query.

public static get_one([array<string|int, mixed> $args = array() ]) : Clarkson_User|null
Parameters
$args : array<string|int, mixed> = array()

User query arguments.

Return values
Clarkson_User|null

get_roles()

Get the user's roles.

public get_roles() : array<string|int, string>
Return values
array<string|int, string>

User roles.

get_user()

Get the WordPress WP_User object.

public get_user() : WP_User
Return values
WP_User

is_current_user()

Check if this user is the currently logged in user.

public is_current_user() : bool
Return values
bool

update_meta()

Update user meta data.

public update_meta(string $key, array<string|int, mixed>|string $value) : bool|int

See: https://github.com/level-level/Clarkson-Core/issues/124.

Parameters
$key : string

User meta key.

$value : array<string|int, mixed>|string

User meta data.

Return values
bool|int

Meta ID if the key didn't exist.


        

Search results