How to create a save/favorite function in Webflow with Memberstack that requires login and persists user selections? Answered
Hey team.
I have a memberstack powered membership webflow site. I want to have a Save/Favorite function where by when a user who is not logged in click on Save/Favorite button, the user is required to signup/login and their chosen template is on a Save/Favorite page.
Is this possible with Memberstack?
Comments
9 comments
Hey Michael Ola, off the top of my head, I believe the simplest approach would be to show a set of save / favorite buttons for the logged out users (which is hidden for logged in users) and have a custom attribute enabled to be able to redirect the users back to the same page they were trying to save an item from, and the users could then just save it (via the buttons that show up for logged in users) once they login / signup.
š to what A J said! And here's a tutorial on how to enable the like/save functionality. https://www.memberstack.com/scripts/save-unsave-items-to-your-collection
Thank you so much
Duncan Hamra I find the above tutorial to be very helpful.
I noticed when a user is not logged in, it doesn't regard their saved item. Is it possible for it to be regarded and have them signup/login when they try to save when not logged in??
Michael Ola, this feature only works for logged in users as of now since Memberstack needs the member data to store their favorites for them uniquely. So, as a workaround you could copy paste those unsave buttons and have them visible for logged out users alone and link them to the signup / login page as suggested earlier. That way, users will signup / login and come back to the same page where they were trying to add the favorites and can proceed by saving the items of their choice. This is the simplest approach I have seen other users setup previously.
If you don't mind custom code, you could further customize and come up with a code to possibly save the item slug in local storage and see if you can push them to the member JSON, once they have logged in etc. I have not explored this use-case, so not sure how far it is feasible, so feel free to further research on what approach would work if you don't prefer the simpler approach shared earlier.
Duncan Hamra This video (https://www.memberstack.com/scripts/save-unsave-items-to-your-collection) has been very helpful. There's another function required which is not stated and I need help with.
On the my collection page (the page showing saved items) I want the user to be able to click and link back to the CMS template page. Kindly assist.
Iāve updated both theĀ save logicĀ and theĀ collection rendering logicĀ so saved items link back to their CMS page.When usersĀ save items, the script stores the CMS page link (
ms-code-link), and on the collection page,Ā images are wrapped inĀ<a>Ā tagsĀ that link back to the CMS template page. If no link was saved, it defaults toĀ"#".That said, an example Save button would look like this:
<buttonms-code-add-buttonms-code-save="item-123"ms-code-category="Posters"ms-code-link="/posters/item-123">Save</button>Do I need to add the attributes above anywhere?Also which item is made Link block or it doesn't matter be it div block or link block.
HeyĀ Michael Ola, just made a minor change in the code shared by Chukwudi. So let me share the steps here:
2. In theĀ main pageĀ where all items are listed, replace the memberscript you have with the following:
In this memberscript, replace 'COLLECTION-SLUG/' with your actual collection slug. For example, say your collection item's url is '_some-site.webflow.io/images/cat-8'. _So in the above code you will replace 'COLLECTION-SLUG/' with 'images/'
That's it. Nothing to change on the buttons or no need to add any link blocks. The layout can be as it is and the code should help you achieve the use-case.
Let me know if you face any blockers.
I have implemented it as described here but it is not working.
But itās been sorted by A J
Thank you Duncan Hamra
Please sign in to leave a comment.