How can I set new user accounts to pending status in a Craft 3 module?
Yeah you’re correct that db089251 is the culprit here, which fixed a bug where user activation events weren’t getting fired when users were first created, if the “Verify email addresses?” setting was disabled.

Your new code is close, but that is going to get called each time Craft tries to activate a user—both when they are first created, and when you try to manually activate a user later on. So you just need to add a condition to your event handler.

As a starting point, maybe just check if it’s a site (front-end) request.

Event::on(
    Users::class,
    Users::EVENT_BEFORE_ACTIVATE_USER,
    function (UserEvent $event) {
        if (Craft::$app-&gt;request-&gt;getIsSiteRequest()) {
            $event-&gt;isValid = false;
        }
    }
);