PHP Class WPCOM_VIP_Support_User, vip-mu-plugins-public

Afficher le fichier Open project: Automattic/vip-mu-plugins-public Class Usage Examples

Protected Properties

Свойство Type Description
$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.

Méthodes publiques

Méthode Description
__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 )

Méthodes protégées

Méthode Description
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.

Method Details

__construct() public méthode

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

action_admin_head() public méthode

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

action_admin_notices() public méthode

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

action_load_profile() public méthode

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

action_load_user_edit() public méthode

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

action_parse_request() public méthode

Hooks the parse_request action to do any email verification.

action_password_reset() public méthode

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

action_personal_options() public méthode

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() public méthode

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() public méthode

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() public méthode

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() public méthode

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
Résultat void

create_check_hash() protected méthode

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
Résultat string The check hash for the values passed

demote_user_from_vip_support_to() protected méthode

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() public méthode

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
Résultat array An array of URL parameter names which are tidied away

filter_wp_redirect() public méthode

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
Résultat string

get_trigger_resend_verification_url() protected méthode

Create and return a URL with a parameter which will trigger the resending of a verification email.
protected get_trigger_resend_verification_url ( ) : string
Résultat string A URL with a parameter to trigger a verification email

get_user_email_verification_code() protected méthode

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
Résultat string A random hex string

init() public static méthode

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
Résultat WPCOM_VIP_Support_User object The instance of WPCOM_VIP_Support_User

is_a8c_email() public méthode

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
Résultat boolean True if the string is an email with an A8c domain

is_verified_automattician() public static méthode

Checks their email address as well as their email address verification status
public static is_verified_automattician ( $user_id ) : boolean
Résultat boolean Boolean indicating if the account is a valid Automattician

mark_user_email_unverified() protected méthode

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 méthode

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 méthode

protected promote_user_to_vip_support ( $user_id )
$user_id

send_verification_email() protected méthode

See the action_parse_request for information about the hash
See also: 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() protected méthode

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
Résultat boolean True if the user has a verified email address, otherwise false

user_has_vip_support_role() public méthode

public user_has_vip_support_role ( $user_id, $active_role = true )

Property Details

$message_replace protected_oe property

Set to a string to indicate a message to replace, but defaults to false.
protected bool|string $message_replace
Résultat boolean | string

$registering_a11n protected_oe property

A flag to indicate the user being registered is an A12n (i.e. VIP).
protected bool $registering_a11n
Résultat boolean

$reverting_role protected_oe property

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