function testClean() { $san = new PSU_Sanitizer_Email(); $this->assertSame(null, $san->clean('')); $this->assertSame(null, $san->clean('bad')); $this->assertEquals('*****@*****.**', $san->clean('*****@*****.**')); }
/** * Check if an email address is tied to this user. */ public function has_email($email) { $san = new PSU_Sanitizer_Email(); $email = $san->clean($email); $wp_email = $san->clean($this->wp_email); $wp_email_alt = $san->clean($this->wp_email_alt); return in_array($email, array($wp_email, $wp_email_alt)); }
/** * Provision an applicant record from self::getApplicant into WordPress. */ function provisionWordPress($applicant) { if (!function_exists('sl_provision_applicant')) { die('Cannot provision a WordPress account: WordPress or login-hacks is not available.'); } if (!filter_var($applicant['email'], FILTER_VALIDATE_EMAIL)) { return new WP_Error('malformed-email', 'A malformed email address has been provided for this user.'); } $sanitizer = new PSU_Sanitizer_Email(); $applicant['email'] = $sanitizer->clean($applicant['email']); $result = sl_provision_applicant($applicant['pidm'], $applicant['email'], $applicant['term_code_entry']); if (false === $result) { return false; } if ($result instanceof WP_Error) { return $result; } if ('active-user' === $result) { return true; } // $result was a user id number $user_data = get_userdata($result); ac_applicant_initial_pw($user_data); return true; }