SignUpAssistantComponent PostProcessPlugin Question

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
Andy608
Posts: 13
Joined: 02 Aug 2017, 05:21

SignUpAssistantComponent PostProcessPlugin Question

Postby Andy608 » 20 Nov 2020, 03:21

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; 
    }
}
User avatar
Lapo
Site Admin
Posts: 21726
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SignUpAssistantComponent PostProcessPlugin Question

Postby Lapo » 20 Nov 2020, 08:21

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
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Andy608
Posts: 13
Joined: 02 Aug 2017, 05:21

Re: SignUpAssistantComponent PostProcessPlugin Question

Postby Andy608 » 21 Nov 2020, 02:50

Great, thanks!

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Aldenea, DavinVicy, DerikFent, JerodSa, Kevengar and 35 guests