Filter articles based on members email address

Hi I am looking to add a section on my members profiles where I can upload personal training sessions which are specific to the member logged in. I will be adding the sessions so I wanted to know if there is a way of doing this without having to physically log into their page but rather add the session on a database that then points the article to the member based on their email?

I hope this makes sense.

Thanks in advance.

Simon

Yes it is. But first add more details regarding how you currently store your users in the database (do you have a collection besides the PrivateMembersData collection?) and how you store the sessions (do you have a collection for the training sessions?).

Hi J.D,

Thank you for your response.

Ones a person has subscribed and signed up a profile is created and their information is stored on a data collection called profile (see code below). I also have a separate data base for my sessions which is called Members Personalised Sessions.

Thank you in advance for your help!

PROFILE CODE

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
$w.onReady( () => {
if (wixUsers.currentUser.loggedIn) {
$w(“#button3”).label = “Logout”;
$w(“#button2”).show();
}
else {
$w(“#button3”).label = “Login”;
$w(“#button2”).hide();
}
} );
export function button3_onclick() {
// user is logged in
if (wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w(“#button3”).label = “Login”;
$w(“#button2”).hide();
} );
}
// user is logged out
else {
let userId;
let userEmail;

// prompt the user to log in
wixUsers.promptLogin( {“mode”: “login”} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query(“Profile”)
.eq(“_id”, userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
“_id”: userId,
“email”: userEmail
};
// add the item to the collection
wixData.insert(“Profile”, toInsert)
. catch ( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w(“#button3”).label = “Logout”;
$w(“#button2”).show();
} )
. catch ( (err) => {
console.log(err);
} );
}
}
export function button2_onclick() {
wixLocation.to(/Profile/Update/${wixUsers.currentUser.id});
}