Database trigger for when a user gets created

Hi,

I have a database trigger for when a new user gets added in the system. (Users could get added via sign-up or via some other workflows which create new users when new leads get generated etc.)

On this trigger I create some internal ID for them, assign a referral code to them etc.

However, I just observed that this database trigger is getting triggered even when anonymous users are getting created e.g. when non logged in users come to the website and browse or when a user logs out etc.

How do I prevent that? I only want to create my internal ID and referral code etc. for my genuine users.

Thanks,
Mukesh

1 Like

I suspect that in the trigger the conditional dynamic expression could reference the user’s email address and determine if it is empty or not empty to decided if it is a user you want to run the workflow actions for.

If the email is empty the user is anonymous and it should not be run…when the email is not empty it is a registered user and the workflow should run.

Learn More

Boston85719 is an expert Bubbler with a decade experience as an educator. Real name Matthew, he has been actively building SaaS apps, marketplace apps, scheduling apps and more for clients, himself and for sale as templates.

As an official Bubble Bootcamp Instructor, he leads Bubble Bootcamps on a regular basis.

Always willing to offer advice via the Bubble Forum, Matthew also offers Private Personal and Group Training Sessions.

Through his site, NoCodeTrainer, Matthew provides a range of tutorials with editor access to help you jumpstart your Bubble development.

Always accessible you can send Matthew a private message via the forum or send an email directly with your requests.

Be sure to checkout the Stripe Integration Course when you are ready to integrate Stripe payments to start monetizing your application via product sales or subscriptions.

Stripe Integration Course

NoCodeTrainer.com

1 Like

Thanks @boston85719 . Yeah that’s what even I came up with meanwhile. It seems to be working too so far.

I am surprised such an issue is not documented and others haven’t faced it so far. I am sure others may have triggers too for new user creations.

1 Like

An update.

@boston85719 that solution didn’t work. I initially thought it was working, but I was checking it wrong.

I reached out to Bubble Support and got the solution.

Solution is that we should put condition as “User before change is empty and User after change is not empty”.

It sounds bit counterintuitive as even temp user is “non empty” you’d think. But that’s how it is and it is not clear why the “email not empty” condition doesn’t work. Apparently they are checking with Bubble engineers and will get back.

Meanwhile I thought I’d put the solution here for others’ benefit.

2 Likes

Actually I spoke too soon. My testing capabilities are quite bad looks like.

So the solution suggested by Bubble Support didn’t work either. I followed up with them and they indeed had an issue that had to be fixed. They have fixed the issue now.

So now the solution suggested by @boston85719 does work. i.e. “Email before is empty and email after is not empty”

Not the case if it was a Bug with Bubble. I often find myself learning a lot about how Bubble actually functions when I report a Bug and hear back about how it is not a Bug but actually the expected behavior…in this case, I am glad it was found out to be a Bug and that Bubble fixed it.