Verification link in email

Hi all,

I’m new in wix . I’m have created a registration page that sends an email to the user containing a link to confirm his account that he is doing. I coded the sending of the email well, but I could not put an activation link inside the email message so that it send it to the confirmation page and verify his account. here are my codes:

Verify Registration page:

import wixLocation from 'wix-location';
import wixUsersBackend from 'wix-users';
import {doApproval} from 'backend/register';

  $w.onReady( () => {
  // get the token from the URLlet token = wixLocation.query.token;
    doApproval(token)
     .then( (result) => {
        if (result.approved){
          // log the user in
          wixUsersBackend.applySessionToken(result.sessionToken);
          console.log("Approved");
         }
        else {
           console.log("Not approved!");
           }
      } );
   } );

Register page:

import wixData from 'wix-data';
  import wixWindow from 'wix-window';
  import wixUsers from 'wix-users';
  import wixUsersBackend from 'wix-users';
  import {doRegistration} from 'backend/register';
  import {sendEmail, sendEmailWithRecipient} from 'backend/email';

  /* send confirmation email to client to activate his account*/function sendFormData() {
       let subject = `Activate your account ${$w("#firstname").value}`;
       let body = `Dear ${$w("#firstname").value} ${$w("#lastname").value},
            
            Thank you for registering on TIMLANDS, we hope you find it rewarding!
            Please note that your account at TIMLANDS needs to be activated.
            Please click on the following URL: xxxxxxxxxx
            If the link above does not work, try copying and pasting it into the address bar 
            in your browser.
            This email is to confirm your registration. If you have received this email by 
               mistake, please notify us.
         
         TIMLANDS Team`;

        const recipient = $w("#email").value;

       /* send confirmation email to client to activate his account*/ 

        sendEmailWithRecipient(subject, body, recipient)
           .then(response => console.log(response)); 

        sendEmail(subject, body)
           .then(response => console.log(response));
     }

email. jsw:

import {sendWithService} from 'backend/sendGrid';

                export function sendEmail(subject, body) {
                   const key = "SG.IIM7kezyQXm4UD........";
                   const sender = "sender@gmail . com";
                   const recipient = "recipient @gmail. com";
                   return sendWithService(key, sender, recipient, subject, body);
                  }

                 export function sendEmailWithRecipient(subject, body, recipient) {
                     const key = "SG.IIM7kezyQXm4UD......";  
                     const sender = "sender @gmail. com";
                     return sendWithService(key, sender, recipient, subject, body);
                  } 

register. jsw :

 import wixUsersBackend from 'wix-users-backend';

          export function doRegistration(email, password, firstName, lastName) {
               
         // register the userreturn wixUsersBackend.register(email, password, {
                  "contactInfo": {
                      "firstName": firstName,
                      "lastName": lastName
                     }
                   } )
                   
                   
                 .then( (results) => {
              // user is now registered and pending approval// send a registration verification email
                    wixUsersBackend . emailUser('verifyRegistration', results . user . id, {
                   "variables": {
                   "name": firstName,
                   "verifyLink": `ht t ps: / verificationpage?token=${results . approvalToken}`

                }
        } );
    } );
 }
       export function doApproval(token) {
         // approve the userreturn wixUsersBackend.approveByToken(token)
         // user is now active, but not logged in// return the session token to log in the user client-side
            .then( (sessionToken) => {
                   return {sessionToken, "approved": true};
            } )
           .catch( (error) => {
                return {"approved": false, "reason": error};
         } );
      }

I want to put the the activation link in the register. jsw to the message body in the register page. as shown in figure below, any help, please!

Have you tried using variables? Step3 in this article → Velo: Creating a Triggered Email | Help Center | Wix.com

Ooh, I did not do that, you solved the problem, thank you

This also could be interessting for me the next time. (Just a notice)