Skip to content

Inactive Users: REPORT mode creates permanent inactive flag#106

Merged
rinatkhaziev merged 6 commits into
productionfrom
fix/PLTFRM-2057-inactive-users-report-mode-permanent-flag
Mar 4, 2026
Merged

Inactive Users: REPORT mode creates permanent inactive flag#106
rinatkhaziev merged 6 commits into
productionfrom
fix/PLTFRM-2057-inactive-users-report-mode-permanent-flag

Conversation

@katag9k

@katag9k katag9k commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Description

In the Inactive Users module, when the mode is set to REPORT (flag only), users flagged as inactive can never have their status cleared through normal login activity.

The record_activity() method unconditionally skips recording activity for users already considered inactive, but the "Unblock" UI that provides the only way to clear the flag is only available in BLOCK mode. This creates a permanent "Inactive User" badge with no built-in resolution path in REPORT mode.

The fix gates the early return in record_activity() on BLOCK mode only, so that in REPORT mode logging in naturally records activity and clears the inactive flag.

Changelog Description

Fixed

  • Fixed a bug where users flagged as inactive in REPORT mode were permanently stuck with the inactive flag after logging back in, because stale last_seen meta was never cleared on login

Pre-review checklist

Please make sure the items below have been covered before requesting a review:

  • This change works and has been tested locally or in Codespaces (or has an appropriate fallback).
  • This change has relevant unit tests (if applicable).
  • This change has relevant documentation additions / updates (if applicable).
  • I've created a changelog description that aligns with the provided examples.

Pre-deploy checklist

  • VIP staff: Ensure any alerts added/updated conform to internal standards (see internal documentation).

Steps to Test

  1. Check out this PR.
  2. Set the inactive users module to REPORT mode.
  3. Create or use a test user and allow them to become flagged as inactive (i.e., their last_seen meta is older than the inactivity threshold).
  4. Verify the user appears in the inactive users report.
  5. Log in as the flagged user.
  6. Verify that the stale last_seen meta is cleared on login and the user is no longer flagged as inactive.
  7. Run the unit tests: phpunit --filter test-inactive-users and verify all tests pass.

@katag9k katag9k marked this pull request as draft March 2, 2026 19:24
@katag9k katag9k marked this pull request as ready for review March 2, 2026 22:45
Comment on lines +148 to +154
if ( self::is_block_action_enabled() ) {
// User needs to be unblocked first.
return;
}

// In REPORT mode, clear the stale last seen meta so the user starts fresh.
delete_user_meta( $user_id, self::LAST_SEEN_META_KEY );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katag9k what do we gain by cleaning this before it gets set again below? Wouldn't the update_user_meta be enough?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think I may have misinterpreted what @rinatkhaziev was suggesting. This whole thing hooks into set_current_user, so clearing the meta is pointless since it gets set again right after during the login process.

@andrea-sdl andrea-sdl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this!!! I left a small comment to better understand if I'm missing a piece of the puzzle :)

@rinatkhaziev rinatkhaziev added this pull request to the merge queue Mar 4, 2026
Merged via the queue into production with commit 1e98515 Mar 4, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants