Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add delete-users-by-role command #57

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

kariae
Copy link
Contributor

@kariae kariae commented Feb 7, 2025

Add delete-users-by-role command

This PR introduces a new WP-CLI command delete-users-by-role that allows for bulk deletion of WordPress users based on their roles.

Features

  • Delete users by specifying roles to delete:
    wp newspack-migration-tools delete-users-by-role --roles=subscriber,author
  • Delete users by excluding specific roles:
    wp newspack-migration-tools delete-users-by-role --exclude-roles=administrator,editor
  • Optional post reassignment:
    wp newspack-migration-tools delete-users-by-role --roles=subscriber --reassign-to=1
  • Dry-run mode for safety:
    wp newspack-migration-tools delete-users-by-role --roles=subscriber --dry-run

Implementation Details

  • Validates roles before processing
  • Handles post reassignment/deletion
  • Includes detailed logging
  • Includes comprehensive test suite
  • Includes workaround for Co-Authors Plus issue #1096

Testing Instructions

  1. Install and activate the plugin
  2. Run the command with --dry-run to preview changes:
    wp newspack-migration-tools delete-users-by-role --roles=subscriber --dry-run
  3. Run without --dry-run to perform actual deletion
  4. Test with both --roles and --exclude-roles parameters
  5. Test with and without --reassign-to parameter

QA Checklist

  • Code follows WordPress coding standards
  • All tests pass
  • Documentation is clear and complete
  • Command handles edge cases gracefully

This command allows bulk deletion of WordPress users based on their roles. Users can be deleted either by specifying roles to delete or roles to preserve.

Features:\n- Delete users by role(s)\n- Exclude specific roles from deletion\n- Optional post reassignment\n- Dry-run mode for safety\n- Detailed logging\n\nIncludes workaround for Co-Authors Plus issue #1096
@kariae kariae requested a review from a team February 7, 2025 01:01
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.

1 participant