Good evening all,
Hopefully someone will be able to assist with that.
I have created a Custom Sign Up form and just trying to transfer all the filled in information into my Custom Dataset (Tennis Players). There should be something wrong/missing in my code, as none of that filled in information transfers to my custom database.
The code is following:
import wixData from 'wix-data'; import wixLocation from 'wix-location'; $w.onReady(function () { $w('#button2').onClick( () => { //button2 is a Sign Up button
let toInsert = {
"name": $w("#input1").value,
"email": $w("#input3").value,
"password": $w("#input4").value,
"plays": $w("#dropdown1").value,
};
//TennisPlayers is my custom dataset
wixData.insert("TennisPlayers", toInsert)
.then( (results) => {
let item = results;
} )
.catch( (err) => {
let errorMsg = err;
} );
});
});
//once registered, transfers new user to his profile page (mii-profile) export function registrationForm1_wixFormSubmit() { wixLocation.to("/mii-profile"); } export function registrationForm1_wixFormSubmitted() { wixLocation.to("/mii-profile"); }
Thanks in advance!
Regards,
Danny
Ну да, больше никто на Виксах не ввязывался в это дело)
I know, indeed ))
Thanks Dima!
Да не сам я, с Виксов там одна помогла, взяла инициативу на себя))
Just want to thank Dima and Kristof first of all, for their time and effort, as well as Wix team member, who found a solution how to make this code to work! I am going to share it below, for anyone who need a code for a custom registration:
import wixData from 'wix-data'; import wixLocation from 'wix-location'; import wixUsers from 'wix-users'; let image; let name; let email; $w.onReady(function () { $w("#uploadButton1").onChange( () => { $w("#uploadButton1").startUpload() .then(resp => { console.log(resp); image = resp.url; }) }) }); export function registrationForm1_wixFormSubmitted() { wixLocation.to("/home"); wixUsers.login($w("#input3").value, $w("#input4").value) .then(() => { console.log("This is the user id:", wixUsers.currentUser.id) let toInsert = { "_owner": wixUsers.currentUser.id, "password": $w("#input4").value, "plays": $w("#dropdown1").value, "name": name, "email": email, }; wixData.insert("TennisPlayers", toInsert) .then( (results) => {console.log(results) let item = results; }) .catch( (err) => { let errorMsg = err; console.log(errorMsg) }); }) } export function input1_change(event) { name = event.target.value; } export function input3_change(event) { email = event.target.value; }
Took a while to reply)
Before i try to explain few things, my question would be the one. Don't you use the PMD (PrivateMembersData)? Surely you do, right?
No, I don't, however I am aware of this database, which just collects/registers the basic user's information
Try now to answer the question by yourself. Do you need this part of CODE?
I don't think so) I got that what you have explained above regarding the code, which will capture user's ID and also will show the IDs of the last 3 registered members.
All I need is the unique ID, which will be allocated for each registered user.
Did you try to register a new Tennis-Player? https://www.media-junkie.com/custom-registration
Yes, I managed to do that))
I want to thank you again Dima, for very detailed explanation and giving me a template to work on in the future!
The most annoying thing now is that Wix customer support member managed to run my initial code (theirs, I suppose to say, as I can't write codes) without any issues and this code does exactly what I need it to do!🤣
I have compared it against the one I have and can't see what is causing the problem. So I guess this my next step, as I can smell the finish line🤣
Thank you Dima!)
It is just simply still too many unknowns to me:
* couldn't find what this does and also what all those inputs stand for:
let myQuery =await wixData.query(myDATABASE) myQuery.find().then((res)=>{console.log("TennisPlayers-Data: ", res)if(res.items.length>0){$w('#input14').value = res.items[0]._owner if(res.items.length>1){$w('#input15').value = res.items[1]._owner}if(res.items.length>2){$w('#input16').value = res.items[2]._owner}
*do I need this part at all:
$w('#BTNopenUserDetails').onClick(()=>{$w('#box2').show();})$w('#IMGclose').onClick(()=>{$w('#box2').hide();})$w('#BTNgetUserDetails').onClick(()=>{getUserDetails(wixUsers.currentUser.id);})
*email and password are log in details if I got it wright, but why do I need to save these other 4 inputs additionally:
wixUsers.register(email, password,{ contactInfo:{"firstName": firstName,"lastName": lastName,"phone": phone,"nickname": nickname }})
*again, didn't get this part either:
asyncfunctiongetUserDetails(){let userID =$w('#input0').value if(userID!==undefined){let userDetails =awaitgetMemberDetails(userID) console.log(userDetails)}else{console.log("Please enter a USER-ID first!")}}
Просто для меня это такие дерби, что тут без программиста не разобраться. Я пробовал гуглить и чем глуже копаю, тем больше вопросов возникает)
Благодарю за ответ и проделанную работа, но...
this code is just too complex for my brain.
I am going to stick to my original one and will try to find a way how to make it work.
Еще раз спасибо и удачи
Thank you Dima, no worries!
Thank a lot for this code, Dima!
I have adjusted mine using yours as an example, however it doesn't work.
Hell knows were the error is, an the code hasn't got any error messages.
import wixData from 'wix-data'; import wixUsers from 'wix-users'; $w.onReady(function() { $w('#button2').onClick(()=>{registration();}) }) function registration () {console.log("Registration done!") let name = $w('#input1').value let email = $w('#input3').value let password = $w('#input4').value let plays = $w('#dropdown1').value let backhand = $w('#dropdown2').value let tennisRacket = $w('#input6').value let country = $w('#input7').value let level = $w('#dropdown3').value let lookingforplayers = $w('#switch1').checked let availability = $w('#checkboxGroup1').value let availability2 = $w('#input8').value let image = $w('#uploadButton1').value let toInsert = { "_owner": wixUsers.currentUser.id, "name": name, "email": email, "password": password, "plays": plays, "backhand": backhand, "tennisRacket": tennisRacket, "country": country, "level": level, "lookingforplayers": lookingforplayers, "availability": availability, "availability2": availability2, "picture": image, } // Registration----------------------------- wixUsers.register(email, password, { contactInfo: { "email": email, "password": password, } }) .then( (results) => {console.log(results)}) .catch( (err) => {console.log(err)}); // Save in MY DATABASE----------------------------------- wixData.insert("TennisPlayers", toInsert) .then( (results) => {console.log(results)}) .catch( (err) => {console.log(err)}); }
Благодарю, но не работает.
Я проверил базу данных, не происходит ввода данных:
Также страничка профиля игрока пустая, что является следствием первой ошибки:
Я попробую объяснить чего я пытаюсь добиться, хотя возможно по коду понятно, я просто в программирование не силен (что было понятно изначальному посту)).
Есть кастомная регистрация, данные которых я пытаюсь перенести в свою базу данных (путем let toInsert, как я понимаю, достигается).
Но мне объяснили товарищи с Викса, что нужен уникальный ИД, для того чтобы информацию с базы данных можно было б перенести на страничку профиля игрока (для этого как я понял нужна registrationForm1_wixFormSubmitted()).
UPLOAD-BUTTON это для аватарки игрока в профиле, Кпонка номер два для ввода регистрационной информации в базу данных после нажатия.
Как-то так))
С Уважением,
Данни
Без Ваших инструкций как это сделать, не сообразил бы)
Вроде так:
import wixData from 'wix-data'; import wixLocation from 'wix-location'; import wixUsers from 'wix-users'; let image; $w.onReady(function () { $w("#uploadButton1").onChange( () => { $w("#uploadButton1").startUpload() .then(resp => { console.log(resp); image = resp.url; }) }) }); export function registrationForm1_wixFormSubmitted() { wixUsers.login($w("#input3").value, $w("#input4").value) .then(() => { console.log("This is the user id:", wixUsers.currentUser.id) $w('#button2').onClick( () => { let toInsert = { "_owner": wixUsers.currentUser.id, "name": $w("#input1").value, "email": $w("#input3").value, "password": $w("#input4").value, "plays": $w("#dropdown1").value, "backhand": $w("#dropdown2").value, "tennisRacket": $w("#input6").value, "country": $w("#input7").value, "level": $w("#dropdown3").value, "lookingforplayers": $w("#switch1").checked, "availability": $w("#checkboxGroup1").value, "availability2": $w("#input8").value, "picture": image, } }) }) }; wixData.insert("TennisPlayers", toInsert) .then( (results) => { console.log(results) let item = results; //see item below } ) .catch( (err) => { console.log(err) let errorMsg = err; } );
Благодарю!
Going to put the exact error messages:
Заранее благодарю)
Sorted. Now the issue with the brackets
Will someone be able to assist with the code? It says "wixUsers is not defined".
I am trying to set up user's ID prior to full registration in order for the registered member to have a chance to update the information on his player's profile page (issue above).
Got an answer from WixSupport team: was a conflict with permissions:)
I have just changed the permission, so anyone can create a content for this collection and now I am able to see the registered players in my database! Brilliant!
The issue I have now, is that information from the dataset doesn't transfer into +My Profile page.
Sorry Kristof, was a little bit busy this weekend.
Not really sure how do I need to change multi selection in order to sort the issue out:
Yes
The checkboxgroup is it an multi selection ? More then 1 option possible?
Thanks Kristof. This is the first thing I did. I was getting an error:
Hi Kristof,
Thank you for this link.
I am a bit confused what exactly to add.
and this what I have add, which seems isn't right (however error on the code has disappeared)
How to open hncow.js in order to debug this code?
Loading the code for the Custom Signup page. To debug this code, open hncow.js in Developer Tools
Regards,
Danny
No worries Kristof, sort your things out first, my code isn't so urgent)
Right, I think I have found the first error:
Regards,
Danny