Need help with user.register.post.post_process script

Hi,

I tried as you suggested. Copied the script as is.

I created the user through the DF Admin -> Create page. No email received.

I used Chromes Rest Client and did a POST to /user/registration. No email received.

Regards,
Allen

Hi,

please copy paste here the body requisition you’re using in Chrome Rest Client and the log file about requisition it self.

Here’s my payload

{
  "email": "someemail@somedomain.com",
  "first_name": "Allen",
  "last_name": "Sandiego",
  "new_password": "password"
}

Replacing someemail@somedomain.com with a valid email address.

Hello @allensandiego .

I just realized that you are using user.register.post.post_process and not system.user.post.post_process, I’m sorry for the confusion.

In this case, you must follow the following steps:
I believe that steps 1 and 2 have already been made by you

1 - Create and configure role to Open Registration

2 - Enable Open Registration and assign created role

3 - Configure event script user.register.post.post_process

var lodash = require("lodash.min.js");

var user = event.request.payload;

var emailPayload = {
    subject: "Welcome",
    body_html:  "{name},<br/><br/>You have successfully registered!",
    from_name: "Allen Sandiego",
    from_email: "email@domain.com",
    name: user.first_name,
    to: {
        name: user.first_name,
        email: user.email
    }
};

platform.api.post("email", emailPayload);
```

Best regards.

Hi,

It seems to be working now.

Although, I think the problem was on this part of the code.

if (event.request.payload.resource) {

Because if I immediately do a post with this like @kimpatro suggested

platform.api.post('email', {
"template": "My Template Name",
  "to": [
    {
      "name": "The Name",
      "email": "super@mail.com"
    }
  ]
});

It would send an email. Only problem I had back then is I can’t reference any of the data the user passes when registering.

Now that I used the following:

var lodash = require("lodash.min.js");
var user = event.request.payload;

var emailPayload = {
    subject: "Welcome",
    body_html:  "{name},<br/><br/>You have successfully registered!",
    from_name: "Allen Sandiego",
    from_email: "email@domain.com",
    name: user.first_name,
    to: {
        name: user.first_name,
        email: user.email
    }
};

platform.api.post("email", emailPayload);

Everything seemd to work out okay.

Thank you all for the help. I think I might be able to proceed now.

Regards,
Allen

2 Likes