Automattic\WooCommerce\Internal\ShopperLists\Privacy
Privacy::erase_data
Erase every stored shopper list for the user matching the given email.
Метод класса: Privacy{}
Хуков нет.
Возвращает
Массив{items_removed:. bool, items_retained: bool, messages: array<int, string>, done: bool}
Использование
$Privacy = new Privacy(); $Privacy->erase_data( $email_address ): array;
- $email_address(строка) (обязательный)
- Email address the request applies to.
Код Privacy::erase_data() Privacy::erase data WC 11.0.1
public function erase_data( string $email_address ): array {
$response = array(
'items_removed' => false,
'items_retained' => false,
'messages' => array(),
'done' => true,
);
$user = get_user_by( 'email', $email_address );
if ( ! $user instanceof \WP_User ) {
return $response;
}
$user_id = (int) $user->ID;
$controller = wc_get_container()->get( ShopperListsController::class );
foreach ( $controller->get_supported_slugs() as $slug ) {
if ( ! Users::delete_site_user_meta( $user_id, ShopperList::META_KEY_PREFIX . $slug ) ) {
continue;
}
$response['items_removed'] = true;
$response['messages'][] = sprintf(
/* translators: %s: shopper-list slug. */
__( 'Shopper List: %s', 'woocommerce' ),
$slug
);
}
return $response;
}