# Restricting user to ONE booking per month

**URL:** <https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646>\
**Category:** Need help\
**Created:** [November 20, 2017, 3:48am UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646 "2017-11-20T03:48:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pc001](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pc001](https://forum.bubble.io/u/pc001)\
**Post date:** [November 20, 2017, 3:48am UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/1 "2017-11-20T03:48:28Z")

</div>

Hey,

I’m trying to limit bookings (with Type = Trial) to one per month for each individual listing on my marketplace.

For example, user can book listing A on the 9th June, and again on the 1st July.

At the moment, when the user clicks the ‘book’ button, I create a new booking with type = Trial.

I’m not sure which constraints to add to make sure they can only book once per month. If user has booked within the current month, I’d like to hide the ‘book’ button completely and replace it with a message.

Here’s what my workflow for a booking (with Type = Trial) looks like at the moment.

 ![create-booking](https://us1.discourse-cdn.com/bubble/original/3X/4/7/47a9ae5718629d2e0d56c222b653e9372197e1a1.png)

Any help would be great! Thanks 🙂

---

<div class="post-metadata">

**Author:** ![am.experts.online](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@am.experts.online](https://forum.bubble.io/u/am.experts.online)\
**Post date:** [November 20, 2017, 7:29am UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/2 "2017-11-20T07:29:50Z")

</div>

I would extract the month from the date of the booking and then check the current date. If it is equal to the date of the last booking then dont show the button.

---

<div class="post-metadata">

**Author:** ![pc001](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pc001](https://forum.bubble.io/u/pc001)\
**Post date:** [November 20, 2017, 4:32pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/3 "2017-11-20T16:32:05Z")

</div>

Should I write that as a conditional on the button? Not sure how I can extract the month from the booking date for the current page user (or should I ‘do a search for’)?

---

<div class="post-metadata">

**Author:** ![louisadekoya](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/louisadekoya/32/217422_2.png) [@louisadekoya](https://forum.bubble.io/u/louisadekoya)\
**Post date:** [November 20, 2017, 5:24pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/4 "2017-11-20T17:24:54Z")

</div>

I suspect that this “extract month” approach, would mean that I could create a booking on the 30th of Nov and again on the 1st of Dec? Is this acceptable? If not then perhaps another approach is to only display the button when the user is not on trial or when they are on trial AND count of bookings where date \> current date/time :+days(-30) is 0. Something like that. Note: I don’t have access to Bubble right now so I can’t look to see if :+months(-1) is possible.

---

<div class="post-metadata">

**Author:** ![pc001](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pc001](https://forum.bubble.io/u/pc001)\
**Post date:** [November 21, 2017, 12:37am UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/5 "2017-11-21T00:37:01Z")

</div>

I considered both:

a.) once per month (so it could be 30th Nov and 1st dec)  
b.) once every 30 days

I’m probably leaning towards once every 30 days right now, but will put more thought into it.

I think the word ‘Trial’ in this case is misleading, as it’s not a ‘trial plan’ but a membership type - so if the user is paying for the ‘trial’ plan, then they have membership until they stop paying.

I’m just a little confused about how to add the functionality - I’m leaning towards on a conditional on the ‘book’ button, and I basically want to say:

When current user has booked this listing within 30 days, this button should be invisible.

Can’t figure out the exact commands (past ‘When current user’)!

---

<div class="post-metadata">

**Author:** ![louisadekoya](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/louisadekoya/32/217422_2.png) [@louisadekoya](https://forum.bubble.io/u/louisadekoya)\
**Post date:** [November 21, 2017, 5:50am UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/6 "2017-11-21T05:50:16Z")

</div>

Try starting with do a search for booking instead, and set constraints to booked by current user, listing = this listing, date within 30 days, then finish with count = 0.

---

<div class="post-metadata">

**Author:** ![pc001](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pc001](https://forum.bubble.io/u/pc001)\
**Post date:** [November 21, 2017, 8:26pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/7 "2017-11-21T20:26:53Z")

</div>

Thanks for the help, think I’m getting there - I’m trying to apply your advice to the ‘book unlimited’ button which displays the actual booking overlay.

I’d like to have the ‘Book Unlimited’ button to disappear if 30 days has not been yet reached (or replace it with a ‘You can book this again in X days’ message), so I’ve done the following:

 ![unlimited_button](https://us1.discourse-cdn.com/bubble/original/3X/c/4/c403187555300610240479364711bb83bd406157.jpg)

Not sure what to add after ‘Search for Bookings’.

 ![search_more](https://us1.discourse-cdn.com/bubble/original/3X/7/a/7abbd7075bae3f90329e95f1517eaf59faaf785f.jpg)

I’ve been able to work through most issues but this one is really puzzling me!

---

<div class="post-metadata">

**Author:** ![louisadekoya](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/louisadekoya/32/217422_2.png) [@louisadekoya](https://forum.bubble.io/u/louisadekoya)\
**Post date:** [November 21, 2017, 8:55pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/8 "2017-11-21T20:55:19Z")

</div>

Don’t you need one more constraint for the date? From your earlier screenshot, I believe the field is selected date. So in addition to Client and ActivityListing, I thought you would set selected date \> current date/time :+days(-30).

> [@pc001](#):
>
> Not sure what to add after ‘Search for Bookings’.

Select :count then type \> 0. **Note** : I’m saying \> because I assume the button is enabled by default and you want to disable or hide it if there is already a listing matching your criteria.

---

<div class="post-metadata">

**Author:** ![pc001](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pc001](https://forum.bubble.io/u/pc001)\
**Post date:** [November 22, 2017, 3:25am UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/9 "2017-11-22T03:25:07Z")

</div>

Yep you’re right, I’ve added the date constraint too. I have this working up to the point where I can affect the button (not clickable + text changed), but I’m not sure how the countdown works.

I changed current date/time :+ **days** (-30) to current date/time :+ **seconds** (-30) to test if the button would revert, but it doesn’t seem to go back to its previous state to allow me to book the listing again.

 ![booking](https://us1.discourse-cdn.com/bubble/original/3X/c/5/c589fac5fba3d383bbfefa31d08f4b7bb3448596.jpg)

I’ve changed ‘Trial’ to ‘Unlimited’ so that it makes more sense.

After 30 days (in this case, 30 seconds), the book button should allow me to book the listing again, that’s the only bit missing so far!

Thanks

---

<div class="post-metadata">

**Author:** ![louisadekoya](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/louisadekoya/32/217422_2.png) [@louisadekoya](https://forum.bubble.io/u/louisadekoya)\
**Post date:** [November 22, 2017, 8:04am UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/10 "2017-11-22T08:04:24Z")

</div>

If you have a booking that matches the criteria then this should work (revert).

Quick test - add a text element to your page within the same group as the button. Copy your search to it, removing the ‘\> 0’ at the end. What is the count you get?

If you still can’t get it to work, consider sharing a link to your application editor.

---

<div class="post-metadata">

**Author:** ![pc001](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pc001](https://forum.bubble.io/u/pc001)\
**Post date:** [November 22, 2017, 4:43pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/11 "2017-11-22T16:43:41Z")

</div>

The count I get is ‘1’, so that’s showing the correct number of bookings.

But after 30 seconds, there is no change (and I don’t know if we’ve commanded it to change) to allow the user to re-book that listing.

Here’s my editor:

---

<div class="post-metadata">

**Author:** ![mguerrasio](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@mguerrasio](https://forum.bubble.io/u/mguerrasio)\
**Post date:** [November 22, 2017, 6:38pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/12 "2017-11-22T18:38:37Z")

</div>

Your app editor isn’t public for viewing. You have to set that in the Setting/General tab.

---

<div class="post-metadata">

**Author:** ![pc001](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pc001](https://forum.bubble.io/u/pc001)\
**Post date:** [November 22, 2017, 6:51pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/13 "2017-11-22T18:51:13Z")

</div>

Strange, I have it set to ‘Everyone can edit’ - anything else I need to do?

Thanks

---

<div class="post-metadata">

**Author:** ![mguerrasio](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@mguerrasio](https://forum.bubble.io/u/mguerrasio)\
**Post date:** [November 22, 2017, 7:06pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/14 "2017-11-22T19:06:52Z")

</div>

Ok, for some reason your link in the forums is the problem. The ampersands are encoded as & which breaks the link. I modified it and I am in your app looking. Stay tuned.

---

<div class="post-metadata">

**Author:** ![mguerrasio](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@mguerrasio](https://forum.bubble.io/u/mguerrasio)\
**Post date:** [November 22, 2017, 7:28pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/15 "2017-11-22T19:28:31Z")

</div>

Ok, here is what I am pretty sure is the issue. Your date-time field in your booking table is of type text, not date. You are trying to see if the TEXT value “11/03/2017 12:00:00” is greater than the DATE value of NOW. Your date-time field needs to be an actual date field type.

Marc

---

<div class="post-metadata">

**Author:** ![pc001](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pc001](https://forum.bubble.io/u/pc001)\
**Post date:** [November 22, 2017, 8:54pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/16 "2017-11-22T20:54:54Z")

</div>

Hey,

Ah - I changed the date-time field to use a date TYPE instead (called Booking date), but the button text isn’t changing/the button isn’t allowing me to book again after 30 seconds. I think everything is configured correctly now.

I’m still trying to comprehend this: **Booking Date \> Current date/time +(seconds) -30**

What does the statement above mean (if you phrased it as a sentence)?

---

<div class="post-metadata">

**Author:** ![mguerrasio](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@mguerrasio](https://forum.bubble.io/u/mguerrasio)\
**Post date:** [November 22, 2017, 9:09pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/17 "2017-11-22T21:09:50Z")

</div>

**Booking Date \> Current date/time +(seconds) -30** means is the date you stored in the “booking date” field greater than (or more specifically LATER than) 30 seconds prior to NOW.

Based on the one record in the booking table that currently has a booking date, your problem is that it has a date in the future. You are presumably storing the date of the class/event/etc. I think what you are trying to do is store the date/time the booking happened. (I booked a class TODAY at 1PM that is scheduled to happen a week from now). You could use Created Date instead.

**Created Date \> Current date/time +(seconds) -30**

---

<div class="post-metadata">

**Author:** ![pc001](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pc001](https://forum.bubble.io/u/pc001)\
**Post date:** [November 22, 2017, 9:50pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/18 "2017-11-22T21:50:12Z")

</div>

Thanks for the explanation - I have it working now! Thanks very much @louisadekoya and @mguerrasio

If a user books class on the 1st December, they will be able to book again on the 31st December. I tested it with -30 seconds and it worked perfectly (after a page refresh) so I’ve scaled it up to 30 days now.

The only thing I don’t have working is a button countdown - when a class can’t be booked, the button says: **You can book this again in X days** - I want X to start at 30 days and countdown daily (not in realtime, just on page refresh).

I found a few guides on Bubble for this so I should be OK but I will ask if I need further assistance.

Thanks again guys

---

<div class="post-metadata">

**Author:** ![louisadekoya](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/louisadekoya/32/217422_2.png) [@louisadekoya](https://forum.bubble.io/u/louisadekoya)\
**Post date:** [November 22, 2017, 10:28pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/19 "2017-11-22T22:28:53Z")

</div>

Try do a search for (latest booking)'s created date +days 30 - current date/time :format as days. It should look something like below, but of course, in your case, the search is for a booking (last unlimited one by the user).

![example2](https://us1.discourse-cdn.com/bubble/original/3X/c/0/c031c2c17188ee6fe47224fb2a437a7d21ad5a75.png)

---

<div class="post-metadata">

**Author:** ![pc001](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pc001](https://forum.bubble.io/u/pc001)\
**Post date:** [November 22, 2017, 11:31pm UTC](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646/20 "2017-11-22T23:31:10Z")

</div>

That seems to work, thanks!

By adding the :first item’s Creation Date, will that apply to the most recent bookings or only the first ever booking?

Thanks again

[Next page](https://forum.bubble.io/t/restricting-user-to-one-booking-per-month/20646.md?page=2)
