Assign a submitted form to specific member

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

Any ideas?

Thanks

Dan

1 Like

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.

https://support.wix.com/en/article/filtering-a-page-based-on-the-currently-logged-in-user

Hi,

The difference is though I’m assigning the diet for them (me as in admin) how do I link that to a members profile?

What field do I need to link together so that its unique to them?

There won’t be just one diet each week it may change and I want to keep the history of them.

I nearly had it using a dynamic page of the diets database but struggling with how to get the unique identifier url.

Cheers

You can use the dataset fields of either ID or Owner, see wix-users for more info and have a read of this page about it here .

Hi,

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?

export function Submit_click(event, $w) {
$w(‘#Checkinswrite’).setFieldValue(‘firstName’, $w(‘#input1’).value);
$w(‘#Checkinswrite’).setFieldValue(‘lastName’, $w(‘#input9’).value);
$w(‘#Checkinswrite’).setFieldValue(‘membersEmail’, $w(‘#input10’).value);

}
id rather not code it if no need

thanks for your time

Hi Dan,

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.

Best,

Justin

Hi Justin,

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.

Dan

Hi Justin

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);
});
});
});

});

hope it helps you too

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.

@beyondobediencetrain
Thank you for the comments on this.

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.

Your help will be much appreciated.

@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

@abs100ro24592 Hi abs100ro,

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?

@abs100ro24592
Why not just look at this Wix tutorial here for a member profile and update page and simply change the design of hte member profile to suit your own needs.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

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

@givemeawhisky That great will explore this link and see if I can resolve this issue.

@beyondobediencetrain Ok thanks will explore this area wixdata.query. If you find any other alternative method let me know.

Andisa, better to start a new post rather than tag onto the end of this one.

For your issue you would have to look at making your own members profile page like here.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

On your first profile page which is read only, you can query any dataset for the current users inputs and have tables or repeaters that display the users chosen form inputs.
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html

Use the eq function to get the userid, something like this
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#eq

 //rest of your code//
wixData.query("Your Dataset Name Here")
.eq("_id", userId)
.find();
//rest of your code//

Although when you say submissions, have you used Wix Forms and created submissions tables for each of them or have you actually created your own custom user input forms?
Wix Forms: Viewing and Managing a Submissions Table | Help Center | Wix.com
https://support.wix.com/en/article/accessing-your-wix-forms-submission-tables

As Wix Forms is a Wix app and not part of Wix Corvid.
Wix Forms | Help Center | Wix.com