init() public static method

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
return WPCOM_VIP_Support_User object The instance of WPCOM_VIP_Support_User
コード例 #1
0
 function test_is_a8c_email()
 {
     $a8c_emails = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**');
     foreach ($a8c_emails as $a8c_email) {
         $this->assertTrue(WPCOM_VIP_Support_User::init()->is_a8c_email($a8c_email));
     }
     $non_a8c_emails = array('*****@*****.**', '*****@*****.**', '*****@*****.**', 'someone@automattic', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**');
     foreach ($non_a8c_emails as $non_a8c_email) {
         $this->assertFalse(WPCOM_VIP_Support_User::init()->is_a8c_email($non_a8c_email));
     }
 }
コード例 #2
0
 /**
  * Marks the user with the provided ID as having a verified email.
  *
  *
  * <user-id>
  * : The WP User ID to mark as having a verified email address
  *
  * @subcommand verify
  *
  * ## EXAMPLES
  *
  *     wp vipsupport verify 99
  *
  */
 public function verify($args, $assoc_args)
 {
     $user_id = absint($args[0]);
     if (!$user_id) {
         \WP_CLI::error("Please provide the ID of the user to verify");
     }
     $user = get_user_by('id', $user_id);
     if (!$user) {
         \WP_CLI::error("Could not find a user with ID {$user_id}");
     }
     WPCOM_VIP_Support_User::init()->mark_user_email_verified($user->user_id, $user->user_email);
     // Print a success message
     \WP_CLI::success("Verified user {$user_id} with email {$user->user_email}, you can now change their role to VIP Support");
 }
コード例 #3
0
 /**
  * Marks the user with the provided ID as having a verified email.
  *
  *
  * <user-id>
  * : The WP User ID to mark as having a verified email address
  *
  * @subcommand verify
  *
  * ## EXAMPLES
  *
  *     wp vipsupport verify 99
  *
  */
 public function verify($args)
 {
     $user_id = absint($args[0]);
     if (!$user_id) {
         \WP_CLI::error("Please provide the ID of the user to verify");
     }
     $user = get_user_by('id', $user_id);
     if (!$user) {
         \WP_CLI::error("Could not find a user with ID {$user_id}");
     }
     // If this is a multisite, commence super powers!
     if (is_multisite()) {
         grant_super_admin($user->ID);
     }
     WPCOM_VIP_Support_User::init()->mark_user_email_verified($user->ID, $user->user_email);
     // Print a success message
     \WP_CLI::success("Verified user {$user_id} with email {$user->user_email}, you can now change their role to VIP Support");
 }
コード例 #4
0
     * @param string $user_email The email of the user to generate the hash for
     *
     * @return string The check hash for the values passed
     */
    protected function create_check_hash($user_id, $verification_code, $user_email)
    {
        return wp_hash($user_id . $verification_code . $user_email);
    }
    /**
     * @TODO Write a method description
     *
     * @param int $user_id The ID of the user to mark as having a verified email
     * @param string $user_email The email which has been verified
     */
    public function mark_user_email_verified($user_id, $user_email)
    {
        update_user_meta($user_id, self::META_EMAIL_VERIFIED, $user_email);
        delete_user_meta($user_id, self::META_VERIFICATION_DATA);
        delete_user_meta($user_id, self::META_EMAIL_NEEDS_VERIFICATION);
    }
    /**
     * @param int $user_id The ID of the user to mark as NOT (any longer) having a verified email
     */
    protected function mark_user_email_unverified($user_id)
    {
        update_user_meta($user_id, self::META_EMAIL_VERIFIED, false);
        update_user_meta($user_id, self::META_EMAIL_NEEDS_VERIFICATION, false);
    }
}
WPCOM_VIP_Support_User::init();