Clear number of User Logins in Members

In Members, I need to clear/delete the #Logins of a user and set it to zero. I looked around but couln’t find a way. All I could do, is delete user and add it again. Would that be the way? Can I do it from within the cms or I need to go to the database?
Thank you for a hint.

Hi @blinkdesign - yeah I don’t think that’s possible through the CMS to my knowledge. I would hesitate to delete the user because they are probably connected to lots of things like page versions and such - resetting the value in the database, while manual, is probably a pretty simple / low stakes update query. Back up your database of course :wink:

Thanks Evan for confirming.

You can actually do it easily with a bit of code.

Add this code at the end of application\bootstrap\app.php

$loggedInUser = new \Concrete\Core\User\User();
// let's only run this code if you're logged in as the superuser
if ($loggedInUser->isSuperUser()) {
    $em = $app->make(\Doctrine\ORM\EntityManagerInterface::class);

    $user = $em->getRepository(\Concrete\Core\Entity\User\User::class)->findOneBy(
            'uName' => 'the_user_name', // or 'uEmail' => 'the_user_email'

    if ($user) {

Replace the_user_name with the username for the user you want to modify. Alternatively, modify the code as explained in the comment if you would like to use the email instead.

If you only would like to set the number of logins to zero but keep the other information (last IP, time of last login…) just remove what you don’t need.

Then, logged in as the superuser, load any page on your website.

That’s it.

Remove the code when you’re done.

That is phantastic, exactly what I was looking for. Thank you Nour.

Concrete is full of surprises :smile: