Wp user delete (WP-CLI)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
$wp help user delete

NAME

  wp user delete

DESCRIPTION

  Deletes one or more users from the current site.

SYNOPSIS

  wp user delete <user>... [--network] [--reassign=<user-id>] [--yes]

  On multisite, `wp user delete` only removes the user from the current
  site. Include `--network` to also remove the user from the database, but
  make sure to reassign their posts prior to deleting the user.

OPTIONS

  <user>...
    The user login, user email, or user ID of the user(s) to delete.

  [--network]
    On multisite, delete the user from the entire network.

  [--reassign=<user-id>]
    User ID to reassign the posts to.

  [--yes]
    Answer yes to any confirmation prompts.

EXAMPLES

    # Delete user 123 and reassign posts to user 567
    $ wp user delete 123 --reassign=567
    Success: Removed user 123 from http://example.com

    # Delete all contributors and reassign their posts to user 2
    $ wp user delete $(wp user list --role=contributor --field=ID) --reassign=2
    Success: Removed user 813 from http://example.com
    Success: Removed user 578 from http://example.com

Remove all customer accounts

Example:

  • Remove all customer accounts
  • Remove all associated content
  • Switch --yes: To confirm that all content should be deleted (there is no intermediary stage like a trashcan for this)
wp user delete $(wp user list --role=customer --field=ID) --yes

Success: Removed user 979 from example.com.
Success: Removed user 977 from example.com.
Success: Removed user 980 from example.com.
Success: Removed user 976 from example.com.
Success: Removed user 974 from example.com.
Success: Removed user 975 from example.com.

See also