top of page
  • Writer's pictureRobert Hebert

Adding sign-up codes for member signup using Velo

Who is our client and what problem did they want to solve?

  • Our client focuses on teaching wellness strategies in school environments.

  • Their website contains private content intended only for certain users.

  • They contacted RHM to help provide a solution that allowed only those certain users to be authenticated upon signup with a special code.

What solution did we provide?

We accomplished this by providing a unique code to each user upon signup. This allowed them to create their account and access the content.

Our client had an existing database of access codes but needed them to be reformatted and de-duplicated.

We created a new `School Codes` content manager database, exported the old data to a CSV, and then created a `data.js` file containing a `SchoolCodes_beforeInsert` function that would run before inserting an item into the `School Codes` database.

When the function runs, it will check the database to see if the school code already exists. If it does, it rejects the insertion. If it doesn't, it transforms the code into all uppercase and proceeds to insert it into the database, thus the data was reformatted and de-duplicated.

How did we implement the solution?

To validate the school code when a new user signed up, we created a 'schoolCodeValidation.jsw' file in the backend, which allows the front end to call backend code.

With `checkSchoolCodeExistence` function, we use the wix-data module to query the `School Codes` database to verify the code exists; if so we return true, otherwise false. This code gets called on the member registration form when the school code is entered. If it is a valid school code, the user is allowed to register and create an account to access the private content.

Check out the code we used below:

import { authentication } from "wix-members";
import wixLocation from "wix-location";
import { checkSchoolCodeExistence } from "backend/schoolCodeValidation";

$w.onReady(function () {
  $w("#register").onClick(async function () {
    let email = $w("#email").value;
    let password = $w("#password").value;
    let accesscode = $w("#accesscode").value;
    let name = "School";

    const validSchoolCode = await checkSchoolCodeExistence(accesscode)
      .then((result) => result)
      .catch((err) => console.log(err));

    if (validSchoolCode) {
        .register(email, password, {
          contactInfo: {
            firstName: name,
        .then(() => {
    } else {

  $w("#accesscode").onChange(async (event) => {
    const value =;
    const validSchoolCode = await checkSchoolCodeExistence(value)
      .then((result) => result)
      .catch((err) => console.log(err));

    if (validSchoolCode) {
    } else {

Our client also had a need to be able to enter new `School Codes` into the database so we created a page with a form that would check for the existence of the school code that they entered and if it didn't exist, allow them to add the school code to the database. Shoot us a message if you want to know more about this code!

Have questions about something similar? Contact us at 225-250-1888 or email

About our company

RHM specializes in helping businesses of all sizes and across all industries achieve their digital and web marketing needs. Whether it's designing a new website, building an app, performing custom development, or running Google Ads, our goal is to showcase how you are the best at what you do and help people connect with you. Contact us at 225-250-1888 to get started!

134 views0 comments


bottom of page