Automattic\WooCommerce\Internal\CustomerEmailVerification\Admin
UserProfileField::save
Persist the "Email address verified" checkbox when a profile is saved.
Method of the class: UserProfileField{}
No Hooks.
Returns
null. Nothing (null).
Usage
$UserProfileField = new UserProfileField(); $UserProfileField->save( $user_id ): void;
- $user_id(int|mixed) (required)
- The user being saved.
UserProfileField::save() UserProfileField::save code WC 11.0.1
public function save( $user_id ): void {
$user_id = (int) $user_id;
if ( ! current_user_can( 'manage_woocommerce' ) ) {
return;
}
$nonce = isset( $_POST[ self::NONCE_ACTION . '_nonce' ] ) ? sanitize_text_field( wp_unslash( $_POST[ self::NONCE_ACTION . '_nonce' ] ) ) : '';
// profile_update fires on every wp_update_user() call, so the nonce is what scopes us to a
// profile-screen submission where our field was actually rendered; without it we would clear
// verification on every unrelated user update.
if ( ! wp_verify_nonce( $nonce, self::NONCE_ACTION . '_' . $user_id ) ) {
return;
}
if ( isset( $_POST[ self::FIELD ] ) ) {
$this->service->mark_verified( $user_id );
} else {
$this->service->clear_verification( $user_id );
}
}