HI, I have a fitness based website where by i need to create diets for my clients.
I want to be able to fill out a form (Me as in admin) and assign it to a member and submit it to a database. ( A drop down of available members would be good to select from )
Then when the member logs in to their own “My diet page” they can see the diets i have created for them but not anyone elses.
I have 2 databases, 1 custom user profile one called Members Profile, and one called Diets. basically i want to fill the diets database myself and have each entry only being able to be viewed by the client i assign it too.
Im sure this is dooable through dynamic pages but not sure how to get the link working for members to view their own diets
Just do the diets page the same as you would the member profile page and have it setup with user id, so that only that one user can view their own profile and diet pages.
I understand where your coming from the issue is the owner will be me the admin as I created the form, how do I have it so when my member looks at his diet page he sees just his diets?
can you give me an example? the only unique id I can tie to it that matches something in the user members profile is their email address or their ID.
how do I create a diet form that contains the user id from members profile? do I need to add that autofill to database using some code? something of this nature? one of the inputs being the user id?
I’m working on something pretty similar myself. I suspect that you’re further along than I am, so I may not be able to offer much. Prior to learning about private member pages, my intention had been to create a dynamic page with my client profiles. My intention was to use two datasets. One for clients, the other for my equivalent of your diets. Each client would then get a link to the dynamic page tied to them, with its own url. I’m expecting to manually add content links from the “diet” dataset to a field in the “client” dataset as each client gains access to new content so it then updates their page.
I still have to look more into private member pages to see if that’s a better solution. I’ll be interested to see if that is the case, if someone suggests a different solution, or if my potential approach is helpful. Good luck and curious to hear what solution you arrive at.
Only way i can do it is to grab the User id from the members profile and add that to a field in the diet database. then in the my diet dynamic page that a member clicks have it filter only based on logged in user matching the id in the field.
Still not done it but that is the plan.
Seen many people asking the same question here but no definitive answer as yet ill let you know when i have done it and its working and ill share the code.
Done it, had to use a table index in a normal page and filter it against members email address it then shows only the logged in users info in the table. got some info from this post
From the table it has clickable links to a dynamic table showing the clients diets.
the code i used to filter the table is as follows
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
$w.onReady( function () {
$w(“#dataset1”).onReady( () => {
wixUsers.currentUser.getEmail()
.then((email) => {
console.log(email, ‘here is the email being sent to filter’);
$w(“#dataset1”).setFilter(wixData.filter()
.eq(“email”, email)
)
.then( () => {
console.log(“Dataset is now filtered”);
})
. catch ( (err) => {
console.log(err);
});
});
});
Thanks Dan, glad you got that worked out. I’m in the throes of it now. Will be trying this out as well as some other things I’ve been looking at. Thanks again for the follow up and congrats on getting yours sorted!
Hi
Your help would be much appreciated I am working on something similar too -
I have linked a input form to the database. Is it possible to provide a unique number to this form for each company. On a on-going bases any update made to this form should update that row instead of adding a new row when input form is submitted.
Hi Abdul, Yes, you should definitely be able to do that. You’ll need a way for the code to identify the user by the unique number. Either they enter the number, some other unique field and you pull the corresponding number from a database, or you pull it based on their login, etc. Once the code has the number, you can query the database for their existing entry, make necessary modifications, then do an update. These are all done with the wixData interface. Alternatively, if you’re using dynamic pages, you can set the page to filter for the current user based on that identifier and may not have to use any code at all. I use both methods in different areas of my site.
When a company log into the member site there is a form button where I am asking them to fill in the form. This form is linked to the database (standard form for all the businesses) whenever they update this form data I want the database to be updated too but without a unique reference the database would not know if it’s a new submission or and existing one that the record needs updating.
@abs100ro Hi Abdul, you can use wixdata.query to see if there are any existing records in the database matching a particular field (the company’s Id, for example.) If there are, update the record. If there aren’t, insert a new record.
@beyondobediencetrain That very helpful.
The only problem with this method is that the live dashboard will be linked to the database. This will provide the incorrect information to Charities until you have applied the wixdata.query. Do you know if I can make one of the form field unique i.e. (email) and linked this to the database.
Many thanks
If I’m understanding the question properly, yes, you can. I’m still a novice myself, so I may be misunderstanding something. I use a derivative of my clients’ emails as their unique identifier. I use this to create their dynamic pages.
The part I’m a bit confused about here is that even if you have a unique identifier, the code is still going to have to retrieve the record from the database, so that doesn’t address the issue of the dashboard showing incorrect information until that’s done. Depending on the design, perhaps you could just not populate the dashboard until the record has been retrieved?
Hey guys I hope I’ll get assistance from the team.
I’m trying to get form submissions made by the site members to be directed into their profiles more like how the sign up email address appears in the profile page but I want all the form submissions to appear in their profiles as per given account.
I need your help