I am building a jobs board for my client. They have three different paid plans for their recruiters that allow them to either upload 1, 2 or unlimited jobs per month. I read on another forum post there might be a way to limit submissions based on paid plans but there was not further information. Has anyone been able to manage this?
You can get the current logged in plan and then disable or enable the submit button (or redirect to another page, or display a message or whatever you want).
See here:
https://www.wix.com/corvid/reference/wix-paid-plans.html#getCurrentMemberOrders
Thank you
I’m fairly new to coding but this is what I’ve pieced together from the Corvid API. This is I’m trying to accomplish although I’m sure at the very least my syntax is incorrect.
function postJobCheck () {
if (wixUsers.currentUser.loggedIn) {
wixPaidPlans.getCurrentMemberOrders()
.then (orders => {
if (wixUsers.currentUser === ‘Employer Starter’ ) {
wixData.query( “jobs” )
.contains( “createdBy” , wixUsers.currentUser.id)
.limit()
.find()
.then(results => {
if (results.items.length > 1 ) {
$w( ‘#btnPostJob’ ).disable();
}
})
} else if (wixUsers.currentUser === ‘Employer Standard’ ) {
wixData.query( “jobs” )
.contains( “createdBy” , wixUsers.currentUser.id)
.limit()
.find()
.then(results => {
if (results.items.length > 2 ) {
$w( ‘#btnPostJob’ ).disable();
}
})
} else if (wixUsers.currentUser === ‘Employer Annual’ ) {
wixData.query( “jobs” )
.contains( “createdBy” , wixUsers.currentUser.id)
.limit()
.find()
.then(results => {
if (results.items.length > 0 ) {
$w( ‘#btnPostJob’ ).enable();
}
})
. catch ((err) => {
console.log(err);
});
}
})
}
}
You can’t write:
wixUsers.currentUser === ‘Employer Starter’
I guess what you wanted to do is:
//....
Promise.all([
wixPaidPlans.getCurrentMemberOrders(),
wixData.query("jobs")
.eq("createdBy", wixUsers.currentUser.id)
.limit(1000)
.find()
])
.then (res=> {
const plans = res[0];
const planNames = plans.map(e => e.planName);//array of plan names
let jobs = [];
if(res[1].items.length > 0) {jobs = res[1].items;}
//now you have a list a plan names (planNames) and a list of jobs and you can do what you want
Erin, did you ever get this to work?