Change user role after creation to match WooCommerce

This commit is contained in:
Jean-Matthieu DECHRISTE 2022-08-25 14:27:45 +02:00
parent faa62bb9ad
commit 99db86f10c

View File

@ -183,6 +183,11 @@ class _AccountRegistrationPageState extends NyState<AccountRegistrationPage> {
username: username, username: username,
), ),
); );
if (wpUserRegisterResponse?.data?.userToken != null) {
await WPJsonAPI.instance.api((request) => request.wpUserAddRole(wpUserRegisterResponse!.data!.userToken, role: "customer"));
await WPJsonAPI.instance.api((request) => request.wpUserRemoveRole(wpUserRegisterResponse!.data!.userToken, role: "subscriber"));
}
} on UsernameTakenException catch (e) { } on UsernameTakenException catch (e) {
showToastNotification(context, showToastNotification(context,
title: trans("Oops!"), title: trans("Oops!"),