\WP_Buoy_User_Settings

Manages user-specific settings for a given user.

Summary

Methods
Properties
Constants
__construct()
get_defaults()
get()
set()
has()
save()
delete()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
get_options()
$user
$options
$defaults
N/A

Properties

$user

$user : \WP_User

The user associated with these settings.

Type

\WP_User

$options

$options : array

User's current settings.

Type

array

$defaults

$defaults : array

List of default values for user profile settings.

Type

array

Methods

__construct()

__construct(integer|\WP_User  $user) : \WP_Buoy_User_Settings

Constructor.

Parameters

integer|\WP_User $user

Returns

\WP_Buoy_User_Settings

get_defaults()

get_defaults(string  $key = null) : mixed

Gets a user setting default, or all defaults.

Parameters

string $key

Returns

mixed

get()

get(string  $key, mixed  $default = null) : mixed

Retrieves a user option.

Parameters

string $key
mixed $default

The value to return if the option doesn't exist.

Returns

mixed —

The current option value, or the $default parameter if the option doesn't exist.

set()

set(string  $key, mixed  $value) : \WP_Buoy_User_Settings

Sets a user option.

Returns the current instance for chaining.

Parameters

string $key
mixed $value

Returns

\WP_Buoy_User_Settings

has()

has(string  $key) : boolean

Checks whether a given option name is set.

Parameters

string $key

The option name.

Returns

boolean

save()

save() : \WP_Buoy_User_Settings

Saves the current options to the database in user meta fields.

If an option doesn't exist in the $options array, after it was deleted with WP_Buoy_User_Settings::delete(), for instance, it will be deleted from the database, too.

Multiple user meta fields are used so that the WP database is more easily queryable to allow, for example, finding all users whose phone company is Verizon. This aids in debugging issues.

Returns

\WP_Buoy_User_Settings

delete()

delete(string  $key) : \WP_Buoy_User_Settings

Removes an option from the current instance's $options array.

Returns the current instance for chaining.

Parameters

string $key

Returns

\WP_Buoy_User_Settings

get_options()

get_options() : array

Retrieves user's Buoy settings from the WordPress database.

Returns

array