wpUserAddRole method
Sends a request to add a role to a WordPress user. Include a valid
userToken
and role
to send a successful request.
Returns a WPUserInfoUpdatedResponse future. Throws an Exception if fails.
Implementation
Future<WPUserAddRoleResponse> wpUserAddRole(
{required String role, String? userToken}) async {
Map<String, dynamic> payload = {};
payload["role"] = role;
// send http request
final json = await _http(
method: "POST",
url: _urlForRouteType(WPRouteType.UserAddRole),
userToken: userToken,
shouldAuthRequest: true,
body: payload,
);
// return response
return _jsonHasBadStatus(json)
? this._throwExceptionForStatusCode(json)
: WPUserAddRoleResponse.fromJson(json);
}