Hi folks, just wanted to ask a quick question so I dont spend hours trying sometthing that isn’t possible.
I want to create a saved search, which i have seen the tutorial @yisrael-wix posted. However, is it possible to create this so that it saves when a user logs-in reagrldess where they login from? Hope this makes sense?
Yes It’s possible, you can use wix storage in any case you wish.
If you’re using wix built-in login system just add a condition in the onReady() function of the page that checked if the current user is logIn, if so use setItem() function in order to save data in the storage.
If you’re using register() function in order to logIn user, just add at the end of the function the setItem() function.
Thanks you @sapirh - I’m by no means a dev (just hacking my way through and learning along the way) I think I’m understanding what you’re saying. I’ll give it a go and see what come of it. trial and error as per usual !!
@thomas80559 You could also save the search data in a database collection that contains the userId and the search data . Then when the user logs in, you would get the user’s search data from the database collection using the userId .
Hi @yisrael-wix Thanks for this. Excuse the late reply, I never recieved a notification on your comment. Apologies for sounding a bit daft, but when you say save the search data in a dataset, I’m struggling to understand how this would work? It’s the “search data” I’m confused with. How would I get the search data in to a new data collection?
@thomas80559 Did you see the Example: Saved Search ? Instead of saving the search parameters using the wix-storage API, you can set up a database collection with the same fields. For example, create a collection with the following fields: userId, prev-title, prev-continent. When a user logs in, you can retrieve their last search parameters by doing a query of the collection by using the userId as the filter.