Repository navigation
Make "Delete subscribers" work on multisite - #229
Merged
Merged
Conversation
It used the site's table prefix for the users and usermeta tables, which on a network are shared: on a subsite the query failed, and on the main site it deleted users who still had roles on other sites. Now subscribers who belong to another site only leave this site, network administrators are left alone, and only a network administrator deletes accounts. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Raw database deletion bypasses WordPress user-removal lifecycles and can leave inconsistent metadata, content, caches, and integrations.
2 open findings
What changed in this PR
Updates subscriber maintenance for WordPress multisite installations.
Changes:
- Uses shared network user tables and site-specific capabilities.
- Distinguishes account deletion, site removal, and retained users.
- Adds multisite-specific notices and reporting.
| File | Description |
|---|---|
plugins/bcc-login/includes/class-bcc-login-settings.php |
Implements multisite subscriber lookup, deletion, removal, and messaging. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- After deleting or removing subscribers, their id, login, slug, email and meta caches are cleared and cached user queries are invalidated, as clean_user_cache() does. Deleting stays in bulk, as before this change, and that choice is now documented on delete_users(). - With OIDC_CREATE_USERS on, the note under the button now says that subscribers who belong to another site are kept. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Problem
"Delete subscribers" (Settings → BCC Login → Maintenance) built the users and usermeta table names from the site's table prefix. On a network those tables are shared by all sites:
wp_N_users, which doesn't exist, so nothing was deleted ("The subscribers could not be deleted").Changes
It now uses
$wpdb->usersand$wpdb->usermeta, with this site's capabilities key.OIDC_CREATE_USERSon, nobody only leaves a site. The login can't add an existing account back to a site, so those users couldn't log in there again. They're kept until their account can be deleted, and the message says so.Testing
In throwaway WordPress 7.0.2 sites on PHP 7.4:
bcc-login-subscriber) are deleted with their meta. The administrator, the editor andbcc-login-memberstay. The message is unchanged. When the lookup fails, nothing changes and the error is shown.OIDC_CREATE_USERSon, the network administrator deleted the subscribers with no other site and kept the two who also belong to site two. The site administrator kept everyone.PHPStan with the CI config passes, and
php -lpasses on PHP 7.4 and 8.4.🤖 Generated with Claude Code