Activate profanity filter for validation
Introduction
This article walks you through how to activate the profanity filter in your namespace to validate the display names and usernames of your players.
- The profanity filter feature currently only validates the usernames and display names of your players.
Prerequisites
- You have added profane words to the default profanity filter database. See Register and manage default profane words.
- You have created and configured a designated profanity filter Extend App or set up your own custom server.
- You have created custom profanity filters in the Admin Portal. See Create and manage custom profanity filters.
Activate profanity filter for display name validation
- In the AGS Admin Portal, go to your game namespace.
- On the sidebar menu, click on Game Setup and go to Profanity Filter > Configurations.
- On the Configurations page, go to list of services sections
- It will shows services have supported profanity filter. Currently we only validates the usernames and display names of your players.
- Turn on status toggle.
- After activating the Profanity filter toggle, select the database filter that will be used from the Profanity database dropdown. You can choose the database for the profanity filter
- Default. See Register and manage default profane words.
- Custom filters See Create custom filters.
Activate profanity filter for display name validation
To activate the profanity filter to validate the display names of your players, follow these steps:
-
In the AGS Admin Portal, select Admin Task > IAM Input Validation on the sidebar menu.
-
In the Display Name section, turn on the Profanity filter toggle.
-
After activating the Profanity filter toggle, select the database filter that will be used from the Profanity database dropdown. You can choose the database for the profanity filter
- Default AGS database filter. See Register and manage default profane words.
- Custom filters See Create custom filters.
-
Click Save.
Activate profanity filter for username validation
To activate the profanity filter to validate the usernames of your players, follow these steps:
-
In the AGS Admin Portal, select Admin Task > IAM Input Validation on the sidebar menu.
-
In the Username section, turn on the Profanity filter toggle.
-
After activating the Profanity filter toggle, select the database filter that will be used from the Profanity database dropdown. You can choose the database for the profanity filter
- Default AGS database filter. See Register and manage default profane words.
- Custom filters See Create custom filters.
-
Click Save.
Implement profanity filter with client SDKs
The validate user endpoint is contained inside the User
class on both Unity and Unreal SDK.
Validate user input
- Unreal SDK
- Unreal OSS
- Unity SDK
To enable this endpoint, specify the FUserInputValidationRequest model to put it into the parameter function. AGS has several validations including Username
, DisplayName
, or UniqueDisplayName
. If the response is valid, then it will return true
. Otherwise, it will return false
with an error message.
FUserInputValidationRequest UserInputValidationRequest{};
UserInputValidationRequest.Username = "badwordsexample";
FUserInputValidationResponse UserInputValidationResponse{};
auto ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient(TEXT("YOUR_KEY"));
auto UserApi = ApiClient->GetUserApi().Pin();
UserApi->ValidateUserInput(UserInputValidationRequest, THandler<FUserInputValidationResponse>::CreateLambda([&](const FUserInputValidationResponse& Response)
{
UE_LOG(LogAccelByteUserServiceTest, Log, TEXT("Success"));
}), FErrorHandler::CreateLambda([&](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogAccelByteUserServiceTest, Warning, TEXT("Error Code: %d, Reason: %s"), ErrorCode, *ErrorMessage);
}));
To enable this endpoint, specify the FUserInputValidationRequest model to put it into the parameter function. AGS has several validations including Username
, DisplayName
, or UniqueDisplayName
. If the response is valid, then it will return true
. Otherwise, it will return false
with an error message.
UserInterface = StaticCastSharedPtr<FOnlineUserAccelByte>(OnlineSubsystem->GetUserInterface());
FUserInputValidationRequest UserInputValidationRequest{};
UserInputValidationRequest.Username = "badwordsexample";
FUserInputValidationResponse UserInputValidationResponse{};
auto ValidateUserInputDelegate = UserInterface->AddOnValidateUserInputCompleteDelegate_Handle(FOnValidateUserInputCompleteDelegate::CreateLambda([&](
const FUserInputValidationResponse& Response, bool bWasSuccessful, const FOnlineError & OnlineError)
{
if (bWasSuccessful)
{
UE_LOG(LogAccelByteUserInterfaceProfanityFilterTest, Log, TEXT("Success"));
}
else
{
UE_LOG(LogAccelByteUserInterfaceProfanityFilterTest, Warning, TEXT("Error. Code: %s, Reason: %s"), *OnlineError.ErrorCode, *OnlineError.ErrorMessage.ToString());
}
}));
UserInterface->ValidateUserInput(LocalUserNum, UserInputValidationRequest);
// ValidateInputRequest accepts DisplayName, Username, Password, and UniqueDisplayName. If a field is unused or unneeded, you can leave it as null.
Models.ValidateInputRequest request = new Models.ValidateInputRequest()
{
DisplayName = displayName,
Username = username
};
Result<Models.ValidateInputResponse> validateResult = null;
AccelByteSDK.GetClientRegistry().GetApi()
.GetUser()
.ValidateUserInput(request, result =>
{
if (result.IsError)
{
// Your code to run when there's an error with the API call
}
// Your code to run when the API call is a success
validateResult = result;
});