How do I get all users

Hi, I have a site with users/contacts. When registering for an event(Not Wix-Event as too restrictive, I have written my own). the email used is the one for the currently logged on user. However, if no-one is logged on the user then enters one. I then want to send an email confirmation to that user. I user wix-crm-backend and wixCrm.createContact, send the email with sendContactEmail and then delete the contact.

HOWEVER, if the user already exists but just hasn’t logged on I get an error when inserting as it would be a duplicate email address. I therefore then want to read that contact and use it’s id for sending the email but I can’t see a way of getting contact by email, or scrolling through all contacts until I get the one with that email.

Any clues please anyone?

Note that if the user on your website is a site member, then you should be using Wix Users, whereas any contact to your website is through the Wix CRM.

What’s the difference between wix-crm and wix-users?
The CRM API contains functionality for working with your site’s contacts. The Users API contains functionality for working with users who are logged-in members. Note that all members are also contacts, but contacts are not necessarily members.

https://www.wix.com/corvid/reference/wix-crm.html
https://www.wix.com/corvid/reference/wix-crm-backend.html

https://www.wix.com/corvid/reference/wix-users.html
https://www.wix.com/corvid/reference/wix-users-backend.html

You can email any user not logged in through Wix Users Backend…

How do I send an email to a user who is not the currently logged-in user?
Using the emailUser() function of wix-users you can only send emails to the currently logged-in user. However, from the backend, using the emailUser() function of wix-users-backend you can send emails to any site member.

Note too that you need to be using Wix Users API on your published site for it to work fully.

Why is the wix-users API not functioning properly when I test my code in preview?
The wix-users API is only partially functional when previewing your site. You need to view a published version of your site to see its full functionality.

Depending on what you have setup already, you can look at doing triggered emails.
https://support.wix.com/en/article/creating-a-triggered-email
https://support.wix.com/en/article/corvid-tutorial-sending-a-triggered-email-to-contacts
https://support.wix.com/en/article/corvid-tutorial-sending-a-triggered-email-to-members

@givemeawhisky Thank you for your reply, however it doesn’t answer the question. What I want to achieve is emailing someone who isn’t a contact or member. I am achieving this by creating a contact and then subsequently deleting it. That doesn’t work though if a contact exists with the same email. What I need to do in that case is find which user/contact has that email. I can then send the email in the usual manner.