Send Triggered Email to a user not logged in

Has anyone ACTUALLY DONE THIS?..i…e… Send email to a Site Member whether logged in or not. Been all thru examples and YouTube. Have yet to find a Working Example. The code snipit in the API docs gives you just enough to get you aggravated!

hello,
to get the userid,you can implement a custom signup to your site and save the email and user id after sign up to a users database

when sending the email,you can get the email of the logged in user and make a query to the users database for a matching email.then get the user id form the results and use it send the email

@iankamaa70 THANK YOU, THANK YOU, THANK YOU. I had not thought of that. I DO have a custom sign up. Now the big question. Is there any way to get the ID for the existing users?

@cwvega76
on the custom sign up,the register function returns an object that contains the user information including the userid.just do a console.log on the result and you will see it

if you have users who have already signed up before you implemented the custom sign up just export their emails and IDs from the private Members Database and add them to the newly created users database

@cwvega76
That is what is mentioned in this Wix tutorial for a members profile.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

You simply create your own dynamic pages and your own Members dataset as shown in the tutorial and you can use your own custom signup lightbox to get the user inputs that you want and the signup lightbox will simply save the user inputs into the Wix CRM and show them in your Contacts List and after your member has been approved, either manually or automatically, the user inputs will be saved into your Members dataset from the tutorial.

The first time that the site member views their own profile page, it will only show the user inputs that you have used on your signup form itself, so simply add whatever you want on there to capture.

import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';

$w.onReady(function () {
    
    $w("#registerButton").onClick( (event) => {
        
   let email = $w("#email").value;
   let password = $w("#password").value;
   let first = $w("#firstName").value;
   let last = $w("#lastName").value;
   // add more inputs if you need //

   wixUsers.register(email, password, {
       contactInfo: {
        "firstName": $w('#firstName').value,
        "lastName": $w('#lastName').value,
        //add more inputs into the contact variable if used //
       }
      } )
      .then( (result) => {
        let resultStatus = result.status;
  wixWindow.lightbox.close();
  wixLocation.to("/home");  //Change the URL ending to whatever page you want to send the user to after they log in.
      } );     
    } );
    
});

This works perfectly and closes after registering details before returning to home page, then both names will be saved in contacts and once site member is approved the member details will be added to ‘members’ database.

However, you can still use either ID field in this new dataset or the existing Members/PrivateMembersData collection as they both will be exactly the same ID for both for each of your site members.

Also, please do note that you need to be testing all of this code in the live published version of your website and not in the preview as Wix Users will not work correctly.

The APIs in wix-users are only partially functional when previewing your site. View a published version of your site to see their complete functionality.

The APIs in wix-users can only be used once the page has loaded. Therefore, you must use them in code that is contained in or is called from the onReady() event handler or any element event handler.

We implemented custom signup in a lightbox SIX months ago. It is working fine. And Yes I know this has to be tested on Live site.

Question: For the INTH time HOW DO I GET THE IDs of SIX existing members who are OFFICERS of the organization that I need to send triggered emails to?

Once I know how to get that we can stop beating this dead horse!

Well then, if you know specifically which members you want to send too already, then like said in previous reply, you can simply just take their existing ID from the dataset and add it to your code.

Simply add it to the code as something like this…
export function myBackendFunction() {
let userId1 = // add here your first members userid

wixUsers.emailUser(“emailID”, userId1)

Then second one…
export function myBackendFunction() {
let userId2 = // add here your second members userid

wixUsers.emailUser(“emailID”, userId2)

And so on…

you can add the userids if all the members in an array
eg
const userid=[‘id_1’,‘id_2’,…,‘id_n’];

then create an async await function to loop through all the user ids while sending the emails

const userid=[‘id_1’,‘id_2’,‘id_n’];

async function send_email(){
for ( var i = 0; i < userid.length; i++) {
await wixUsers.emailUser(“emailID”, userid[i]);
}
return “done sending emails”;
}

Hey JD … yes … I got it to work. I tested it out right now. Let me create an updated tutorial to show you how to do this … I got your back :wink:

@code-queen
Great! Let me know when it’s published!
You’re the best!

Hi! Hope you are doing great. Did you update the tutorial? If so, could you share a link with us? Thanks so much for your help :blush:

@code-queen

Where you able to update the tutorial. I have the same problem and have not been able to find a solution.

Thanks

@code-queen

I have the same problem and need the tutorial/help with this too! :slight_smile:

Thanks