Wix code to let visitors to submit a limit number of books to a form database according to paid plan .

i have a paid plan web sites to let members in basic plan for example to upload or submit only one book to a database form i was created … in gold plan a member upload only 3 books …in platinum upload 5 books
please help

The link below prevents member from submitting more than 1 form to a database, you can just modify the code slightly to allow 3 and 5 submissions…

many thanks i will try

hello
really i find a big problem in java script i dont know java i am good in visual basic .
is there any alternative ways like add counter in a form to let members to enter 1 time in basic
3 times counter in gold and so on … but how i can add java script for this condition and where?

You are going to have to code in java script one way or another to achieve what you are trying to do. Are you physically trying to stop them submitting data to your collection a certain number of times if they are a basic/premium member ?

If your answer is yes then you would have to query the collection to see if they have submitted previously. Even if you want to count the number of times they have submitted and display that on screen you still have to query the collection to see how many times they have submitted to the collection.

Am i missing something, are you trying to achieve something else ?

hello
thank you foR your answer
really I have a problem with java script I don’t know ….my web site is ready to finish
I want to let user member who pay for example basic plan upload 1 book only
I want to let user member who pay for example gold plan upload 3 books only
I want to let user member who pay for example premium plan upload 5 books only

I don’t know java and where i put the code i wander if there is a tutorial for that …or please i want a code for my request and where i should add it

If your wanting to learn the basics of how to code on Wix then you should look on YouTube there are plenty of tutorial videos there.

If you you do not wish to use the code I provided and want someone else to to work on your site then you can get someone here: https://www.wix.com/arena/web-designers/1

hello
really i appreciate your patient, ive got your JS code from previous client request but i need please a correction if need since till now i have a problem … add add my words bold please check… add add this code in wix dashboard …settings…tracking&analytics in the body for my page basicsubmit…is it right ?

my database = client-book
my form for client database to submit 1 book = basissubmit
my e mail input box for form = emailinput
my email field for database = e-mail
submitbutton1 = as it is
errortext = as it is

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;

$w.onReady(function () {

if (wixUsers.currentUser.loggedIn) {

let user = wixUsers.currentUser;

console.log(user);

    user.getEmail() 

        .then((email) => { 

let userEmail = email;

console.log(userEmail);

//here we automatically set the email input to the logged in member’s email address

$w(" emailInput ").value = userEmail

wixData.query(" basicsubmit ") //change this to the name of your database

    .eq(" **e-mail** ", userEmail)  //"email is the name of the field in your database, change as necessary" 

    .limit(1) 

    .find() 

    .then((results) => { 

let allResults = results.totalCount;

console.log(allResults);//this should log 0 if they have never submitted a form before

if (allResults > 0) {

console.log(“member submitted form previously”);

$w(“#submitButton1”).disable(); //change the id of the button as necessary

$w(‘#errorText’).show(‘FadeIn’); //change the id of error text as necessary, note you should set text to hidden on load in properties menu for the text

}
})
})
}
})

The code looks ok.

You need to turn on developer tools and paste all the above code into the page code box.

Then test it and see what it says in the developer console when you preview the site.

hello please sir i attached error image and the code appear in the page …at the beginning appear automaticaly ca i delete it until the line i add it ? i appreciate your patient

export function button2_click(event) {
if ($w(“#uploadButton3”).value.length > 0) {
$w(“#text43”).text = Uploading ${$w("#uploadButton3").value[0].name};
$w(“#uploadButton3”).startUpload()
.then( (uploadedFile) => {
$w(“#text43”).text = “Upload successful”;
$w(“#image1”).src = uploadedFile.url;
})
. catch ( (uploadError) => {
$w(“#text43”).text = “File upload error”;
console.log(Error: ${uploadError.errorCode});
console.log(uploadError.errorDescription);
});
}
else {
$w(“#text43”).text = “Please choose a file to upload.”;
}
}
//Add your code for this event here:

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;

$w.onReady( function () {

if (wixUsers.currentUser.loggedIn) {

let user = wixUsers.currentUser;

console.log(user);

    user.getEmail() 

        .then((email) => { 

let userEmail = email;

console.log(userEmail);

//here we automatically set the email input to the logged in member’s email address

$w(“#emailInput”).value = userEmail

wixData.query(“client-book”) //change this to the name of your database

    .eq("e-mail", userEmail)  //"email is the name of the field in your database, change as necessary" 

    .limit(1) 

    .find() 

    .then((results) => { 

let allResults = results.totalCount;

console.log(allResults);//this should log 0 if they have never submitted a form before

if (allResults > 0) {

console.log(“member submitted form previously”);

$w(“#submitButton1”).disable(); //change the id of the button as necessary

$w(‘#errorText’).show(‘FadeIn’); //change the id of error text as necessary, note you should set text to hidden on load in properties menu for the text

}
})
})
}
})