Login Count in user table

Hi all! I would like to add a login counter in the users table.

Any idea on how to do it?

Thanks!!

Hi!! No ideas on this one? please I need help on this one.
Thanks!

Set a number field in the Users database, set a Rule on your Login form to assign the “Login Count” to Arithmetic of +1

1 Like

I only see login redirect rules and the standard login form @PTSIoT

Whoops… I have some similar counts in place with other forms, I had not considered the lack of Submit Rules on a Login form. Is there some sort of ‘first action’ required by the user immediately after logging in, that could be counted instead? For example, my Users have to select a ‘Ticket’ from a ‘Profile’ form to begin using the app (and each ticket they change tickets), and I count how many tickets they open in this manner.

Still curious about a solution for this one.

I believe we can achieve this by creating a custom login-log table. I implemented it in my own way, and it might be helpful to you.

  1. Create Data Table “Login Log” which has 2 fields.

  2. Add Field : Equation → Count, Name: “Login Count”

  3. Pipes → Install “Tadabase Rest API” → Copy Code of “Save New Record” pipe

  4. Goto “Page Builder → Login → Javascript” Tab add below code. for you knowledge “login_success” will trigger everytime when user login successfully.

TB.render('component_4-login_success', function(data) {

}); 
  1. Add your copy pipe code inside Tb.render snippet . data.user.id return current user ID.
TB.render('component_4-login_success', function(data) {
    TB.triggerPipe('PIPE_ID', 
    	{ tableId: '{LOGIN_LOG TABLE ID}', field_id: '{LOGIN_LOG -> USER FIELD SLUG}', field_val: data.user.id },
    	function(type, response, xhrRespone) {
    		
    	}
    );
});

Everytime user loign it create new record in Login Log table and automatically show total count in each user table.

1 Like

@christopher93 Thanks. It works well, but I tried it several times and then it works too well. Which means every time I login the code gets repeated, so I get several entries in the login table.
First time 1 entry, second time 2, etc…

It seems that logout does not delete this code snippet in memory.

Do you recognize this behaviour?

And for getting time/date a table rule needs to be installed