PHP 클래스 WPCOM_VIP_Support_User, vip-mu-plugins-public

파일 보기 프로젝트 열기: Automattic/vip-mu-plugins-public 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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