How to send confirmation email to admin role instead of user's email address

Hello there,

I have requirement for email confirmation on signup, where confirmation link will be sent to admin’s email instead of sign up user.

Once admin confirm’s email (same way like currently user click the link to confirm it) , another email should send to user to notify that admin confirm/approved for new user

Flow:
1.New sign-up => 2.admin will receive email to approve => 3.Admin click’s link from email to approve => 3. Send new user email to notify confirmation => 4. User can login to system

how can i archive this with backendless? Is there any config to add Admin-email for confirmation instead of user?

Hello @Swapnil_G

We have discussed this matter with the team.
You can implement this in two ways:

  1. Create an event handler that will set user status as disabled after registration and send the admin a registration message.
  2. Create an API service that has a method that will activate the user and send him a message about successful registration. (If admin needs some UI page, customer can create it in builder).
    image (1)

Regards, Nazar

Thanks @Nazar_Dmytryshyn for response !

I will try to build the functionality the way you suggested. Will post you back if found any difficulty.

@Nazar_Dmytryshyn Thanks for suggestion.

I have tried the same

  1. Create an event handler that will set user status as disabled after registration and send the admin a registration message.

Created New handler with following
category : Users
event: register
Timing: after

new event handler

and below is the logic same as you menioned

Event handler deployed status

Real time logs in backendless for event handlers

Issue:
When New signup request get sent from frontend, new user is getting created in users table.
but not getting email and /register api also return 400 error code (error message : User objectId must be non empty string)

Also user status get set to null
Screenshot 2022-09-30 at 6.41.47 PM

Hello @Swapnil_G

Try changing the logic as in the screenshot below:

Regards,
Inna

Thanks @Inna_Shkolnaya
changed logic as per your screenshot.

i have disabled email confirmation: PFA


still getting this error : “Cannot send email with the default Email Settings. Change the Email Settings in the console and try again”"
PFA

To use the email API, you need to add your own mail server settings.

This is described in our documentation:
https://backendless.com/docs/rest/email_settings.html

Regards,
Mark

@mark-piller Can we use email template to instead of ‘send email api’ ?

As i have to send confirmation link to admin on new user registration/signup.
Once Admin click that link users status get change to ‘enable’ and user will get email that admin approved/confirmed entry.

Sending an email with template still uses the email API, so you would still need to add your mail server configuration.

Thanks @mark-piller . I tried with mail server and its working.

But i have to send {app_name} and {confirmation_url} in email.
How can i access this in event handler’s send-email block.

Hello @Swapnil_G

  1. Create Codeless service with a method that will activate the user:

  2. Place a link to this method in the afterRegister event handler in the block with the text of the email to be sent to the administrator. Use objectId instead of smart text {userId}
    When the user registers, the admin will receive an email with a link to activate the user

Regards,
Inna

Thanks @Inna_Shkolnaya. It’s working and got confirmation_url in mail.

right now on confirmation link click its just showing ‘null’ text on page

i have to show confirmation (default system confirmation) page on click of email link like below

How can redirect to page created in frontend UI builder?

Hi @Swapnil_G ,

To redirect to the confirmation page build by UI Builder you should explicitly specify link for that page in your email.

right now on confirmation link click its just showing ‘null’ text on page

What link do you receive in email?

Regards, Andriy

Hello @Swapnil_G

I recommend for your method “activateUser” (as in my screenshot above) which will activate the user for return to insert the link to the page you want. This way, once the admin clicks the link and confirms the user, they will be redirected to the page you specified in the method.

Regards,
Inna

Yes @Inna_Shkolnaya.

May i know where can i found confirmation page link created by backendless UI-builder?

I tried to return link for testing but it’s just get displayed on email verification link click. Its should redirect like backendless default confirmation flow.

Hi @Swapnil_G,

find the page you want in the UI Builder and select it (if you want the default confirmation page, it’s allocated under the system container), then click on the Open Published App icon in the top-rigth corner (see the red arrow pointing this). The page will be opened in the new browser tab, there you can copy the URL of the page and use it in your email.

Regards,
Stanislaw

Thanks @stanislaw.grin
I have added confirmation page url to return in activeUser api logic block.

But it’s just show page with string url when email link get click.

How can i redirect to that page link directly when user clicks email confirmation link?

Thanks in advance!

Hello @Swapnil_G

Could you show us how you use this API service? I see that it returns a string, but how would you like to use it later?

This topic can be useful for you:

Regards,
Marina

Hello @Marina.Kan

on new user sign up admin will receive email to verify user.

so created an API service that has a method that will activate the user and send him a message about successful registration or verification by admin.

Every thing is working fine. But when admin clicks confirmation link from email, it open new tab with blank page, instead of this i have to show/redirect to backendless system confirmation-page (it’s in ui builder).

To achive this i have returned confirmation-page url from api-service (can find screenshot in last reply).

@Swapnil_G, thank you for the description. We are looking for a solution. We will contact you as soon as we have the results.

Regards,
Marina