Database options

I have created several user input buttons in order to collect information. Apart from the user input button I have also created a special cell on the (linked to those buttons) database in order to inform users about their membership. I, as thee admin, am the only one who can write on this specific cell, so there is a box that informs members about dates. Could I send notifications to users when their membership ends? Or could this box turn e.g. RED when the membership is outdated?


With respect,
Konstantinos Damalas

Hi Konstantinos!

All of the above are possible with a lil’ bit of WixCode!
It is all matter of a simple condition to add.
It would look something like that:

let currentDate = new Date( );
if ( currentDate > Membership ){
    //alert the user about expiration of the membership
}

I would suggest to generate the currentDate and the Membership in the same way to prevent later issues regarding different formats of dates.

As for alerting the user,
You can use a simple hidden text or box that will pop once the user is logged and the condition above is valid (using hide( ) / show( ) ).
Another option is to alert the user via email using Wix triggered emails.

Hope it helps.
Best of luck!

Doron. :slight_smile:

This was really helpful! Tahnk yu so much Doron!

Hey Doron! May I ask you something again?
I have followed wix’s tutorial to create my own members area using wix code. Velo Tutorial: Building Your Own Members Area | Help Center | Wix.com
However now I am facing a quite weird situation. When I am trying to see this function on the preview mode, there is a message saying “error” and then I can not go back to editor mode unless I refresh the page. (I enclose a photo of the problem)


O n the contrary, on the published mode, I can see clearly this section and make changes.
Since I am not an expert, the only thing that I notice is that on the code, my database is not recognised as a database but as a normal phrase.


Shouldn’t I care about this and continue with the published site or this is something that should be fixed? What is your opinion about that?

Hi!

Please share a link to your site so I can inspect it and provide you with a solution.

Doron. :slight_smile:

Its just a matter of the right quotation marks.
It seems like you used backticks ( ) instead of regular ones ( ’ ’ ).
Once you change it the code will turn pink.

Other than that, I believe that the 404 is due to the fact that when you preview the page you use your own user and not one that exists in the database.
If the issue persists please feel free to contact me again.

Doron. :slight_smile:

When I changed the quotation marks as you said it really turned pink. However nor to the preview mode or on the live published site I could enter “My Profile” page. I changed again quotation marks to the previous form ( ) and now it’s just like before. The published mode works and the preview mode says error 404. Anyway I copied and pasted code from wix site so quotation marks are just like on wix. I followed one by one the steps to creat this form and it’s quite weird that it worked perfectly 2 days before. I also want to remind you that when I enter the preview mode and click “Log out” or “My profile” the systems stucks and I have to refesh the page even if I lose my latest settings. I am quite new to this that’s why I insist disturbing you. I you feel like helping me I would appreciate that. I you don’t feel like that no bad feelings at all. Thank you in advance! Kostas!

After taking a second look I think the problem is originate in the promptLogin function.

//row 33
wixUsers.promptLogin( {"mode": "login"} )
      .then( (user) => {
            userId = user.id;
            return user.getEmail();
         } )

This way you let your site visitors to login without actually signing them up to your database.
It means that they login to your site but no record of that is saved thus making the currentUser.id useless and when you redirect to a dynamic page you get a broken link (the 404).

Change the first line mentioned to:

wixUsers.promptLogin( {"mode": "signup"} )

And let me know if it worked for you.

Also, I advise you to read this article regarding login options.

Doron. :slight_smile:

P.s.
Of course that I feel like helping you!
That is what I do. And I do not feel disturbed, I’m glad to assist you!

Hey again Doron! You must have been waiting for a positive answer! Unfortunately, I used your changes and nothing happened again. However, I think I found something. I have a feeling that the problem starts from the database. I deleted everything and I started again creating my dynamic page. When I created the dynamic page and tried the preview mode the error massage came up. This, additionally to the fact that inside the last part of the code, my database should be in blue letters (as it is in the tuttorial and during my first trial where the page worked) , instead it is black, and when I change quotation marks it turns pink. What do you think about this idea? Plus, I have nothing in my mind how to fix this and it drives me crazy!
Desperately, Kostas