How to determine first login of a user?

Re: How to determine first login of a user?

by Benjamin Ellis -
Number of replies: 4
Picture of Particularly helpful Moodlers
Hi,

There is a 'firstaccess' field in the User table that might be useful.
Average of ratings: Useful (2)
In reply to Benjamin Ellis

Re: How to determine first login of a user?

by Christian Wolters -
Hi Benjamin,

thank you for getting back to me : )

You are right, 'firstaccess' does give me the timestamp of the first login.

However, using this method I would have to define a time interval between first access and time of access
in which the information would be displayed.

I'm hestitating to implement this, as this does not work ideally in the following use case

* first time login -> user is presented with profile fields to complete
* user closes (for whatever reason, but it happens a lot) browser before completing profile
* user accesses moodle a again, three days later -> user is presented with profile fields to complete

Now in this case, firstaccess is already three days old.

Therefor, it can not be the only criteria to base the decision on.

Does anyone know, how moodle determines the redirect to to /user/edit.php to complete custom profile files on login?

Cheers
Christian
In reply to Christian Wolters

Re: How to determine first login of a user?

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That's an easy question to answer. If the user has missing profile fields (off the top of my head, the fields checked are "firstname", "lastname", "email", but you can always check by looking for the function "user_not_fully_set_up()"), then the user is redirected on login. If those fields are filled in, then the user is not redirected.

As for your original question - why not simply add a checkbox to the user profile page for the user to tick when they've read and understood the instructions. That way you can keep sending them back there (by customising the user_not_fully_set_up() function) until they tick the box.
Average of ratings: Useful (4)
In reply to Davo Smith

Re: How to determine first login of a user?

by Christian Wolters -
Yes! Thank you 🙏 That was exactly the kind of function I was looking for!

Indeed, what a nice suggestion, I'll experiment in that direction.

Best regards
Christian
Average of ratings: Useful (1)