PHP Класс WPCOM_VIP_Support_User, vip-mu-plugins-public

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$message_replace boolean | string Set to a string to indicate a message to replace, but defaults to false.
$registering_a11n boolean A flag to indicate the user being registered is an A12n (i.e. VIP).
$reverting_role A flag to indicate reversion and then to prevent recursion.

Открытые методы

Метод Описание
__construct ( ) Class constructor. Handles hooking actions and filters, and sets some properties.
action_admin_head ( ) Hooks the admin_head action to add some CSS into the user edit and profile screens.
action_admin_notices ( ) Hooks the admin_notices action to add some admin notices, also resends verification emails when required.
action_load_profile ( ) Hooks the load action on the profile screen to send verification email if required.
action_load_user_edit ( ) Hooks the load action on the user edit screen to send verification email if required.
action_parse_request ( ) Hooks the parse_request action to do any email verification.
action_password_reset ( object $user )
action_personal_options ( object $user ) Hooks the personal_options action on the user edit and profile screens to add verification status for the user's email.
action_profile_update ( integer $user_id ) Hooks the profile_update action to delete the email verification meta when the user's email address changes.
action_set_user_role ( integer $user_id, string $role, array $old_roles ) Hooks the set_user_role action to check if we're setting the user to the VIP Support role. If we are setting to the VIP Support role, various checks are run, and the transition may be reverted.
action_user_register ( integer $user_id ) Hooks the user_register action to determine if we're registering an A12n, and so need an email verification. Also checks if the registered user cannot be set to VIP Support role (as not an A12n).
action_wp_login ( $user_login, WP_User $user ) : void Hooks the wp_login action to make any verified VIP Support user a Super Admin!
filter_removable_query_args ( array $args ) : array Hooks the removable_query_args filter to add our arguments to those tidied up by Javascript so the user sees nicer URLs.
filter_wp_redirect ( $location ) : string Filters wp_redirect so we can replace the query string arguments and manipulate the admin notice shown to the user to reflect what has happened (e.g. role setting has been rejected as the user is not an A12n).
init ( ) : WPCOM_VIP_Support_User Initiate an instance of this class if one doesn't exist already. Return the WPCOM_VIP_Support_User instance.
is_a8c_email ( string $email ) : boolean Is a provided string an email address using an A8c domain.
is_verified_automattician ( $user_id ) : boolean Determine if a given user has been validated as an Automattician
mark_user_email_verified ( integer $user_id, string $user_email )
user_has_vip_support_role ( $user_id, $active_role = true )

Защищенные методы

Метод Описание
create_check_hash ( integer $user_id, string $verification_code, string $user_email ) : string The hash sent in the email verification link is composed of the user ID, a verification code generated and stored when the email was sent (a random string), and the user email. The idea being that each verification link is tied to a user AND a particular email address, so a link does not work if the user has subsequently changed their email and does not work for another logged in or anonymous user.
demote_user_from_vip_support_to ( $user_id, $revert_role_to ) Demote a user to a
get_trigger_resend_verification_url ( ) : string Create and return a URL with a parameter which will trigger the resending of a verification email.
get_user_email_verification_code ( integer $user_id ) : string Provide a randomly generated verification code to share via the email verification link.
mark_user_email_unverified ( integer $user_id )
promote_user_to_vip_support ( $user_id )
send_verification_email ( integer $user_id ) Send a user an email with a verification link for their current email address.
user_has_verified_email ( integer $user_id ) : boolean Check if a user has verified their email address.

Описание методов

__construct() публичный Метод

Class constructor. Handles hooking actions and filters, and sets some properties.
public __construct ( )

action_admin_head() публичный Метод

Hooks the admin_head action to add some CSS into the user edit and profile screens.
public action_admin_head ( )

action_admin_notices() публичный Метод

Hooks the admin_notices action to add some admin notices, also resends verification emails when required.

action_load_profile() публичный Метод

Hooks the load action on the profile screen to send verification email if required.
public action_load_profile ( )

action_load_user_edit() публичный Метод

Hooks the load action on the user edit screen to send verification email if required.

action_parse_request() публичный Метод

Hooks the parse_request action to do any email verification.

action_password_reset() публичный Метод

public action_password_reset ( object $user )
$user object A WP_User object

action_personal_options() публичный Метод

Hooks the personal_options action on the user edit and profile screens to add verification status for the user's email.
public action_personal_options ( object $user )
$user object The WP_User object representing the user being edited

action_profile_update() публичный Метод

Hooks the profile_update action to delete the email verification meta when the user's email address changes.
public action_profile_update ( integer $user_id )
$user_id integer The ID of the user whose profile was just updated

action_set_user_role() публичный Метод

Hooks the set_user_role action to check if we're setting the user to the VIP Support role. If we are setting to the VIP Support role, various checks are run, and the transition may be reverted.
public action_set_user_role ( integer $user_id, string $role, array $old_roles )
$user_id integer The ID of the user having their role changed
$role string The name of the new role
$old_roles array Any roles the user was assigned to previously

action_user_register() публичный Метод

When a user is registered we reset VIP Support role to inactive, then wait until they recover their password to mark their role as active. If they do not go through password recovery then we send the verification email when they first log in.
public action_user_register ( integer $user_id )
$user_id integer The ID of the user which has been registered.

action_wp_login() публичный Метод

Hooks the wp_login action to make any verified VIP Support user a Super Admin!
public action_wp_login ( $user_login, WP_User $user ) : void
$user_login The login for the logging in user
$user WP_User The WP_User object for the logging in user
Результат void

create_check_hash() защищенный Метод

The hash sent in the email verification link is composed of the user ID, a verification code generated and stored when the email was sent (a random string), and the user email. The idea being that each verification link is tied to a user AND a particular email address, so a link does not work if the user has subsequently changed their email and does not work for another logged in or anonymous user.
protected create_check_hash ( integer $user_id, string $verification_code, string $user_email ) : string
$user_id integer The ID of the user to generate the hash for
$verification_code string A string of random characters
$user_email string The email of the user to generate the hash for
Результат string The check hash for the values passed

demote_user_from_vip_support_to() защищенный Метод

Demote a user to a
protected demote_user_from_vip_support_to ( $user_id, $revert_role_to )
$user_id
$revert_role_to

filter_removable_query_args() публичный Метод

Hooks the removable_query_args filter to add our arguments to those tidied up by Javascript so the user sees nicer URLs.
public filter_removable_query_args ( array $args ) : array
$args array An array of URL parameter names which are tidied away
Результат array An array of URL parameter names which are tidied away

filter_wp_redirect() публичный Метод

Filters wp_redirect so we can replace the query string arguments and manipulate the admin notice shown to the user to reflect what has happened (e.g. role setting has been rejected as the user is not an A12n).
public filter_wp_redirect ( $location ) : string
$location
Результат string

get_trigger_resend_verification_url() защищенный Метод

Create and return a URL with a parameter which will trigger the resending of a verification email.
protected get_trigger_resend_verification_url ( ) : string
Результат string A URL with a parameter to trigger a verification email

get_user_email_verification_code() защищенный Метод

Stored in the same serialised user meta value: * The verification code * The email the verification code was generated against * The last time this method was touched, so we can calculate expiry in the future if we want to
protected get_user_email_verification_code ( integer $user_id ) : string
$user_id integer The ID of the user to get the verification code for
Результат string A random hex string

init() публичный статический Метод

Initiate an instance of this class if one doesn't exist already. Return the WPCOM_VIP_Support_User instance.
public static init ( ) : WPCOM_VIP_Support_User
Результат WPCOM_VIP_Support_User object The instance of WPCOM_VIP_Support_User

is_a8c_email() публичный Метод

Is a provided string an email address using an A8c domain.
public is_a8c_email ( string $email ) : boolean
$email string An email address to check
Результат boolean True if the string is an email with an A8c domain

is_verified_automattician() публичный статический Метод

Checks their email address as well as their email address verification status
public static is_verified_automattician ( $user_id ) : boolean
Результат boolean Boolean indicating if the account is a valid Automattician

mark_user_email_unverified() защищенный Метод

protected mark_user_email_unverified ( integer $user_id )
$user_id integer The ID of the user to mark as NOT (any longer) having a verified email

mark_user_email_verified() публичный Метод

public mark_user_email_verified ( integer $user_id, string $user_email )
$user_id integer The ID of the user to mark as having a verified email
$user_email string The email which has been verified

promote_user_to_vip_support() защищенный Метод

protected promote_user_to_vip_support ( $user_id )
$user_id

send_verification_email() защищенный Метод

See the action_parse_request for information about the hash
См. также: VipSupportUser::action_parse_request
protected send_verification_email ( integer $user_id )
$user_id integer The ID of the user to send the email to

user_has_verified_email() защищенный Метод

Check if a user has verified their email address.
protected user_has_verified_email ( integer $user_id ) : boolean
$user_id integer The ID of the user to check
Результат boolean True if the user has a verified email address, otherwise false

user_has_vip_support_role() публичный Метод

public user_has_vip_support_role ( $user_id, $active_role = true )

Описание свойств

$message_replace защищенное свойство

Set to a string to indicate a message to replace, but defaults to false.
protected bool|string $message_replace
Результат boolean | string

$registering_a11n защищенное свойство

A flag to indicate the user being registered is an A12n (i.e. VIP).
protected bool $registering_a11n
Результат boolean

$reverting_role защищенное свойство

A flag to indicate reversion and then to prevent recursion.
protected $reverting_role