Users
in package
Common user functionality.
Provides data for registration, previous login and last login dates. Provides for user lists by role.
Tags
Table of Contents
Constants
- LAST_LOGIN_KEY = 'pnet_login_last'
- Metadata key for last login.
- PREVIOUS_LOGIN_KEY = 'pnet_login_previous'
- Metadata key for previous login.
- REGISTRATION_KEY = 'user_registered'
- Metadata key for registration date.
Properties
- $instances : array<string|int, object>
- The array of instances of this class and sub-classes.
Methods
- get_by_role() : array<string|int, mixed>
- Return users selected by role, or all users.
- get_instance() : object
- Creates and/or returns the instance of this class.
- get_last_login_date() : string
- Return the last login date for a user.
- get_previous_login_date() : string
- Return the last but one login date for a user.
- get_registration_date() : string
- Returns the registration date for a user.
- __construct() : void
- Initialise the class.
Constants
LAST_LOGIN_KEY
Metadata key for last login.
public
string
LAST_LOGIN_KEY
= 'pnet_login_last'
Tags
PREVIOUS_LOGIN_KEY
Metadata key for previous login.
public
string
PREVIOUS_LOGIN_KEY
= 'pnet_login_previous'
Tags
REGISTRATION_KEY
Metadata key for registration date.
public
string
REGISTRATION_KEY
= 'user_registered'
Tags
Properties
$instances
The array of instances of this class and sub-classes.
protected
static array<string|int, object>
$instances
= array()
Tags
Methods
get_by_role()
Return users selected by role, or all users.
public
get_by_role(string $role) : array<string|int, mixed>
The all users case is provided for consistency.
Parameters
- $role : string
-
The user role.
Tags
Return values
array<string|int, mixed> —An array of WP_User objects.
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_last_login_date()
Return the last login date for a user.
public
get_last_login_date(int $user_id) : string
Parameters
- $user_id : int
-
User id.
Tags
Return values
string —The last login date string, or null.
get_previous_login_date()
Return the last but one login date for a user.
public
get_previous_login_date(int $user_id) : string
Parameters
- $user_id : int
-
User id.
Tags
Return values
string —The previous login date string, or null.
get_registration_date()
Returns the registration date for a user.
public
get_registration_date(int $user_id) : string
Parameters
- $user_id : int
-
User id.
Tags
Return values
string —The registration date string, or null.
__construct()
Initialise the class.
protected
__construct() : void