Hi! i have a code that add new members info to my database when they login. The problem is that when i test the code on preview mode, it works fine, but when i do it on live mode, nothing happens. Anyone know which should be the problem?
This is my login code ( sorry for the image, an error show up when i try to paste the code).
Thanks!!
@Crypto Trade
I had similar problem. It worked in Preview but not in live. The thing is that while you are in Preview mode, the current user is Admin and do not have any restrictions.
In the doRegistration function or any function that is dealing with contacts and members' info, you need to use options. Options are declared as following.
const options = { "suppressAuth": true, "suppressHooks": true };
Depending on the functions that you use, you may put a code similar to this:
// Get the contact's last revision number const myContact = await contacts.getContact(parContactId, options); const contactIdentifiers = { contactId: parContactId, revision: myContact.revision };
Further information you may find in https://www.wix.com/velo/reference/wix-crm-backend/contacts-obj/getcontact.
Hope it helps.
PS Kudos to wixsupport that guided me to find the solution that works. The trick was that any function that is related to Contacts and Members needs to have Options to bypass the default (collection) permissions. Needless to say, you need to use these functions in your backend.
Now, i will leave you. You are very close to solve it! And i am sure, you will be able to solve the rest by your own.
Let me know, when you got your SOLUTION!
And do not forget to like it, if you really liked it 😉.
Time to go to bed! Over and out!
I did it but is the same. I can register and login perfectly , but it always enter to the members page under the same ID.
@Anastasiu Constantin @Velo-Ninja @Rajjat Garg
I´m trying with the register code and the console gives me:
It is taking always the same ID.
Code:
In your original code, try to use 'wixData.save' instead of 'wixData.insert' , maybe will work as you like.
@Velo-Ninja if i try with this other code:
The console give me this:
Please heeelp!
@Velo-Ninja same problem if i do it with registration code! It is like de ID got stuck whatever the user that enters.
Console
Registration Code
The console showed this. The code always gets the same ID, so no new items are created in the database. Help please!