PA_User
in package
The PuzzleAnywhere User class. It allows for an easy way to display a user's account data.
Table of Contents
- $active : bool
- The user's active state.
- $active_subscriber : bool
- Denotes whether the user is an active subscriber, and can actively download puzzles.
- $authentication_token : string
- The current user authentication token.
- $created_at : string
- The datetime as when the user has been created.
- $email : string
- The user email address.
- $email_suspended : bool
- Denotes whether the user's email address has been `suspended`.
- $email_suspension_reason : string|null
- The reason as to why a user's email address has been `suspended`.
- $future_subscriptions : array<string|int, PA_Subscription>|null
- Any upcoming subscriptions for the user.
- $has_subscribed : bool
- Denotes whether the user has an active subscription.
- $id : int
- The user ID.
- $latest_active_subscription : PA_Subscription
- The latest active subscription of the user.
- $latest_subscription : PA_Subscription
- The latest active or expired subscription of the user.
- $name : string
- The user display name.
- $renewal_url : string
- The current user renewal URL.
- $subscriber_status : string
- The current user subscription status.
- $subscriber_status_display : string
- The humanized current user subscriber status.
- $subscription_about_to_expire : bool
- Denotes whether the user's subscription is about to expire.
- $username : string
- The user username.
- authenticate() : PA_User
- Authenticate a user.
- get_account() : PA_User
- Get the user's account data.
- get_auth_token() : string
- Retrieve the locally stored authentication token.
- get_auth_username() : string
- Retrieve the locally stored authentication username.
- get_by_id() : PA_User
- Get a user by the user ID.
- get_email_prefs() : array<string|int, PA_NewsletterType>
- Retrieve email preferences .
- get_email_prefs_by_token() : array<string|int, PA_NewsletterType>
- Retrieve email preferences via user token.
- get_purchases() : array<string|int, PA_Purchase>
- Retrieves the active user's purchases.
- get_stored_user() : PA_User
- Retrieve the locally stored user.
- get_subscription_status() : string|false
- Retrieve the user's subscription status.
- get_user_id() : int
- Retrieve the locally stored user ID.
- get_user_subscriptions() : array<string|int, PA_Subscriptions>
- Retrieves the active user's subscriptions.
- is_logged_in() : bool
- Denotes whether the user is actively logged in.
- nag_subscriber() : bool
- Denotes whether the user should be nagged to renew their subscription.
- reset_auth_storage() : null
- Reset locally stored authentication values.
- set_email_prefs() : array<string|int, PA_NewsletterType>
- Update a user's email preferences.
Properties
$active
The user's active state.
public
bool
$active
The user's active state.
$active_subscriber
Denotes whether the user is an active subscriber, and can actively download puzzles.
public
bool
$active_subscriber
Returns true if the user is an active subscriber.
$authentication_token
The current user authentication token.
public
string
$authentication_token
The current user authentication token.
$created_at
The datetime as when the user has been created.
public
string
$created_at
The datetime as when the user has been created.
The user email address.
public
string
$email
The user email address.
$email_suspended
Denotes whether the user's email address has been `suspended`.
public
bool
$email_suspended
If an email address has been suspended, we will no longer send
emails to them without the email being re-validated, either by
the user, or by a tech or admin.
Whether the user's email address has been suspended.
$email_suspension_reason
The reason as to why a user's email address has been `suspended`.
public
string|null
$email_suspension_reason
The reason as to why a user's email address
has been suspended.
$future_subscriptions
Any upcoming subscriptions for the user.
public
array<string|int, PA_Subscription>|null
$future_subscriptions
Subscriptions for some providers can be stacked, meaning that
a user can purchase futurre subscriptions.
Upcoming subscriptions for the user
$has_subscribed
Denotes whether the user has an active subscription.
public
bool
$has_subscribed
Denotes whether the user has an active subscription.
$id
The user ID.
public
int
$id
The user ID.
$latest_active_subscription
The latest active subscription of the user.
public
PA_Subscription
$latest_active_subscription
The latest active subscription of the user.
$latest_subscription
The latest active or expired subscription of the user.
public
PA_Subscription
$latest_subscription
The latest active or expired subscription of the user.
$name
The user display name.
public
string
$name
The user display name.
$renewal_url
The current user renewal URL.
public
string
$renewal_url
Accessing the URL displays all available renewal options for the user.
The current user renewal URL.
$subscriber_status
The current user subscription status.
public
string
$subscriber_status
The current user subscription status.
$subscriber_status_display
The humanized current user subscriber status.
public
string
$subscriber_status_display
The humanized current user subscriber status.
$subscription_about_to_expire
Denotes whether the user's subscription is about to expire.
public
bool
$subscription_about_to_expire
Returns true if the user's subscription is about to expire.
$username
The user username.
public
string
$username
The user username
Methods
authenticate()
Authenticate a user.
public
static authenticate(string $email, string $password) : PA_User
Parameters
- $email : string
-
The user's email address.
- $password : string
-
The user's password.
Return values
PA_User —The authenticated user.
get_account()
Get the user's account data.
public
get_account() : PA_User
Return values
PA_User —The full user data.
get_auth_token()
Retrieve the locally stored authentication token.
public
static get_auth_token() : string
Return values
string —The locally stored authentication token.
get_auth_username()
Retrieve the locally stored authentication username.
public
static get_auth_username() : string
Return values
string —The locally stored authentication username.
get_by_id()
Get a user by the user ID.
public
static get_by_id(int $uid) : PA_User
Parameters
- $uid : int
-
The user ID.
Return values
PA_User —The found user.
get_email_prefs()
Retrieve email preferences .
public
get_email_prefs() : array<string|int, PA_NewsletterType>
Return values
array<string|int, PA_NewsletterType> —The user's subscribed newsletters.
get_email_prefs_by_token()
Retrieve email preferences via user token.
public
static get_email_prefs_by_token(string $token) : array<string|int, PA_NewsletterType>
Parameters
- $token : string
-
The user token.
Return values
array<string|int, PA_NewsletterType> —The user's subscribed newsletters.
get_purchases()
Retrieves the active user's purchases.
public
get_purchases() : array<string|int, PA_Purchase>
Return values
array<string|int, PA_Purchase> —The user's purchases.
get_stored_user()
Retrieve the locally stored user.
public
static get_stored_user() : PA_User
Return values
PA_User —The locally stored user.
get_subscription_status()
Retrieve the user's subscription status.
public
get_subscription_status() : string|false
Return values
string|false —The user's subscription status. [active|expired|expiry_looming|expiry_imminent|future]
get_user_id()
Retrieve the locally stored user ID.
public
static get_user_id() : int
Return values
int —The locally stored user ID.
get_user_subscriptions()
Retrieves the active user's subscriptions.
public
get_user_subscriptions() : array<string|int, PA_Subscriptions>
Return values
array<string|int, PA_Subscriptions> —The active user's subscriptions.
is_logged_in()
Denotes whether the user is actively logged in.
public
static is_logged_in() : bool
Return values
bool —Returns true if the user is actively logged in.
nag_subscriber()
Denotes whether the user should be nagged to renew their subscription.
public
nag_subscriber() : bool
Return values
bool —Returns true if the user should be nagged to renew their subscription.
reset_auth_storage()
Reset locally stored authentication values.
public
static reset_auth_storage() : null
Return values
null —set_email_prefs()
Update a user's email preferences.
public
set_email_prefs([mixed $newsletter_type_ids = [] ][, mixed $email_offers = [] ]) : array<string|int, PA_NewsletterType>
Parameters
- $newsletter_type_ids : mixed = []
- $email_offers : mixed = []
Return values
array<string|int, PA_NewsletterType> —The user's email prefs.