Page 1 of 1

SignUpAssistantComponent PostProcessPlugin Question

Posted: 20 Nov 2020, 03:21
by Andy608
Hello, I am following this article on the SmartFoxServer website about PostProcessPlugins:
http://docs2x.smartfoxserver.com/Extens ... activation

In one of the examples, under the "Custom Email Fields" section, it uses the variable "age" without referencing it anywhere. I originally thought maybe it's coming from the params variable, but it looks like params is for sending data back to the client. Do you know how I can access this information to check here?

Thanks,
Andy

Code from the website (age is used in the if statement without being referenced anywhere earlier):

Code: Select all

private final class MyPostProcessPlugin implements ISignUpAssistantPlugin
{
    private final String zoneName;
     
    public MyPostProcessPlugin(String zoneName)
    {
        this.zoneName = zoneName;
    }
     
    @Override
    public void execute(User user, ISFSObject params, SignUpConfiguration config) throws SignUpValidationException
    {
        // By default we just insert a line break
        String message = "<br />";
         
        // If age below 18 we show a message
        if (age < 18)
            message = "<p>Since your age is below 18, in-game purchases will not be available</p>";
                     
        Map<String, String> customMailFields = new HashMap<String, String>();
        customMailFields.put("${ageComment}", message);
        customMailFields.put("${gameWelcome}", "Welcome to the " + zoneName + " game.");
         
        // Pass the new fields to the Component's configuration
        config.emailResponse.customEmailFields = customMailFields; 
    }
}

Re: SignUpAssistantComponent PostProcessPlugin Question

Posted: 20 Nov 2020, 08:21
by Lapo
Hi,
thanks for pointing this out. There is indeed a missing line in the example :?
It should look like this instead:

Code: Select all

int age = params.getInt('age');
if (age < 18)
{
   ...
}


We'll fix the code snippet in the docs.

Cheers

Re: SignUpAssistantComponent PostProcessPlugin Question

Posted: 21 Nov 2020, 02:50
by Andy608
Great, thanks!