Hi Folks!
I hope someone is able to help me with this problem.
I have dynamic pages that display information about resources on them. Site visitors can sign up and become a member but I have an additional signup layer so they can’t access some pages on the site until an admin manually approves them as a member (we want to check that they work in a certain industry before they’re approved). It can be up to 24 hours before they’re approved (separate problem, not relevant to this post). During that 24 hour period, I want them to be able to gain access to some site pages that are open to any site visitor. The dynamic resource pages are set so anyone can access them but I want to prevent access to a reviews strip on the page unless they’re signed in and approved. In order to read reviews and post a review of the resource, the page visitor needs to be a logged in member who has also been approved by an admin. If they’re a logged in member, I need to query a “MembersInfo” database to check if they’re approved (this uses an approved/not approved boolean value). The boolean Field Key is aprooveMember. When I add the MembersInfo dataset to the dynamic page, it self-assigns a label of “dataset2”. When a page visitor clicks on the “reviews” button, I want to query if they’re logged in and approved. If they fulfill both criteria, the reviews section should expand. If they’re logged in but not approved, I want to trigger a lightbox (currently called “name” but I’ll change that later) to advise them they’re not approved yet. If they’re not logged in, I want to prompt the login lightbox.
The code below isn’t working. Who is able to help with this? I’m interested to know if I have the code wrong or if there’s anything else I need to change or do.
Thanks.



The red dot in the margin is a warning about a syntax issue. Looks like you don’t have a closing brace for the if statement. So, the end of it should be
} else {
wixUers.promptLogin();
}
}
Thanks Anthony. That’s it!? You’re not seeing any other problems?
@simontmunro13802 The let statement initializing the Approved variable is not really doing anything because the dataset is not yet loaded, but you’re getting that assigned successfully in the onReady. No problem there.
I would just put the following lines after the assignment in the onReady to be sure that it’s returning what you expect, that the dataset is indeed on the record that you think it is. It will return the whole record when you don’t specify the field.
let item = $w("#dataset2").getCurrentItem();
console.log(item);
Other than that, nothing jumps out at me.
Great! Thanks Anthony. I’ll test these changes and update this post with the result.
I think I’ve implemented what you suggested correctly but I’m still getting a few red dots. Maybe I haven’t done this quite right?
Any additional suggestions you may have would be greatly appreciated.
Sorry, I wasn’t clear about the first response. I meant only that you can’t assign the variable Approved a dataset value at that point. You still need to initiate the variable like do the others:
let Approved;
Be sure to hover the mouse over the red dots in the margin to see what the problem is.
Thank you, Anthony.
As you can tell, my coding knowledge is limited. The developer I was working with completed everything I hired him to do so I’m trying to add this code to this page myself!
I think you were suggesting I substitute the word item for the word Approved. Doing that, I have the screenshot below. I have one error left that says “Approved is not defined”.
I think there’s still something I’m not doing right in the onReady?
Make it the last variable declared above the onReady function.
let user = wixUsers.currentUser;
let Approved;