Events and Members - how to make them play nice.

I am working on a site for a club. Using the Wix code examples, I have created the ability for members to login and create/display/update their profile. I used this code:

I would have liked to use WixEvents for my event management (as it is very slick) but (at this time) you cannot post RSVP status. It is important for my use case for members to see who is coming to an event.

So I created my own collection for events (name, date, location, …).

So now I have two collections, one for members and one for events .

I then use a gallery to display my event collection and when one clicks on a gallery item, I have a dynamic page that lists details on the event. All is good.

I also want the currently logged in user to be able to RSVP for each event. We rarely have more than five event on the schedule so each user has 5 events “slots” in each member record (event1 - event 5) which has a value of “yes”, “no”, “maybe”.

I added a radio button that allows the user to set their RSVP status (see attached). My desired function is:

  1. Logged in Member selects RSVP Status from radio buttons

  2. Logged in Member selects “RSVP” button (this executes a "Submit)

  3. Logged in Member event element (one of five) is set to RSVP status (yes, no, maybe)

The issue I have is that I have added the “member dataset” to the dynamic event page but it brings in the ENTIRE dataset. I get this.

How do make it so that the radio buttons are mapped to the logged in member and not the first record in the member dataset? There must be a way to set the current member record to the current member that is logged in? I am guessing in using onReady()? But how?

Many thanks for any help you can provide!!

Hi dmz, first of all: Amazing job! :slight_smile:

I think that in this case, maybe it would be more clear to use wixData module to get the users row and update it, instead of using the Data set.

In you ‘submit’ button, you can update the users line. Here’s a skeleton, adjust it to your needs:

import wixData from 'wix-data';
import wixUsers from 'wix-users';

export function submitButton_click(){
    const currentUser = wixUsers.currentUser;
    if (currentUser.loggedIn) {
        currentUser.getEmail().then(email => {
            wixData.query('members').eq('email', email).find()
            .then(result => {
                const items = result.items;
                //check that we found the user in database
                if (items.length > 0) {
                    const userItem = items[0];
                    //Here do some updates such as
                    //userItem.events = .....
                    wixData.update('members', userItem);
                }
            });
        });
    } else {
         //no user is logged in, do something (or not)
    }
}

Liran.

This looks great - many thanks!

I ended up getting some help from my son and between both of you, I am set.

Thanks again for your help!