User
in package
Site users functionality.
Applies to any person with login credentials.
Tags
Table of Contents
Constants
- ABOUT_IMAGE_KEY = 'psite_about_image'
- The user about image key name.
- NEW_USER_DEFAULTS = array('use_ssl' => true, 'show_admin_bar_front' => 'false', 'role' => 'subscriber')
- New user default values.
Properties
- $instances : array<string|int, object>
- The array of instances of this class and sub-classes.
- $settings : Settings
- The instance of the Settings class.
- $user_home_url : string
- The fully qualified path to the user home page.
Methods
- create() : WP_Error
- Create a new user.
- get_data() : array<string|int, mixed>
- Return the user data and metadata.
- get_instance() : object
- Creates and/or returns the instance of this class.
- get_user_home_url() : string
- Get the user home page url.
- update() : WP_Error
- Update the user.
- __construct() : void
- Initialise the class.
- sanitise_user_data() : array<string|int, mixed>
- Sanitize the user data.
- sanitise_user_meta() : array<string|int, mixed>
- Sanitize the user meta data.
- set_home_page() : void
- Set the user page properties.
Constants
ABOUT_IMAGE_KEY
The user about image key name.
protected
string
ABOUT_IMAGE_KEY
= 'psite_about_image'
Tags
NEW_USER_DEFAULTS
New user default values.
protected
array<string|int, mixed>
NEW_USER_DEFAULTS
= array('use_ssl' => true, 'show_admin_bar_front' => 'false', 'role' => 'subscriber')
Tags
Properties
$instances
The array of instances of this class and sub-classes.
protected
static array<string|int, object>
$instances
= array()
Tags
$settings
The instance of the Settings class.
protected
Settings
$settings
Tags
$user_home_url
The fully qualified path to the user home page.
protected
string
$user_home_url
= ''
Tags
Methods
create()
Create a new user.
public
create(WP_Error $errors, array<string|int, mixed> $user_data[, array<string|int, mixed> $user_meta = array() ]) : WP_Error
Parameters
- $errors : WP_Error
-
The WP_Error object to use if errors.
- $user_data : array<string|int, mixed>
-
The user data.
- $user_meta : array<string|int, mixed> = array()
-
The user custom metadata.
Tags
Return values
WP_Error —The maybe modified error object.
get_data()
Return the user data and metadata.
public
get_data([int $user_id = 0 ]) : array<string|int, mixed>
Parameters
- $user_id : int = 0
-
The target user id.
Tags
Return values
array<string|int, mixed> —$data { The user data and metadata. This may also include metadata added by other plugins and the core. @type string $description The user description. @type string $display_name The preferred display name. @type string $facebook The user facebook account ID. @type string $first_name The user first name. @type string $goodreads The user goodreads account ID. @type int $ID The user id. @type string $instagram The user instagram account ID. @type string $last_name The user last name. @type int $last_update The date the record was last updated. @type string $linkedin The user linkedin account name. @type string $locale The user preferred locale. @type string $nickname The user nickname. @type int $pnet_about_image_id The ID of user image. @type string $pnet_login_last The last login date and time. @type string $pnet_login_previous The previous login date and time. @type string $spotify The user spotify account name. @type string $twitter The user X(Twitter) account handle. @type string $user_activation_key The key used user activation and password reset. @type string $user_email The user email address. @type string $user_login The user login name. @type string $user_nicename The user nicename. @type string $user_pass The encrypted user password. @type string $user_registered The user registration date. @type string $user_url The url to the user home page. @type array $wp_capabilities The array of capabilities assigned to this user. @type string $youtube The user youtube channel id. }
get_instance()
Creates and/or returns the instance of this class.
public
static get_instance() : object
Tags
Return values
object —The instance of this class.
get_user_home_url()
Get the user home page url.
public
get_user_home_url() : string
Tags
Return values
string —The user home page url.
update()
Update the user.
public
update(WP_Error $errors, int $user_id, array<string|int, mixed> $user_data[, array<string|int, mixed> $user_meta = array() ]) : WP_Error
Parameters
- $errors : WP_Error
-
The WP_Error object to use if errors.
- $user_id : int
-
The id of the user to update.
- $user_data : array<string|int, mixed>
-
The user data.
- $user_meta : array<string|int, mixed> = array()
-
(Optional) The user custom metadata.
Tags
Return values
WP_Error —The maybe modified error object.
__construct()
Initialise the class.
protected
__construct() : void
Tags
sanitise_user_data()
Sanitize the user data.
protected
sanitise_user_data([array<string|int, mixed> $user_data = array() ]) : array<string|int, mixed>
Parameters
- $user_data : array<string|int, mixed> = array()
-
The incoming user meta data.
Tags
Return values
array<string|int, mixed> —The sanitised user meta data.
sanitise_user_meta()
Sanitize the user meta data.
protected
sanitise_user_meta([array<string|int, mixed> $user_meta = array() ]) : array<string|int, mixed>
Parameters
- $user_meta : array<string|int, mixed> = array()
-
The incoming user meta data.
Tags
Return values
array<string|int, mixed> —The sanitised user meta data.
set_home_page()
Set the user page properties.
protected
set_home_page() : void