Wp user (WP-CLI)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

wp user: Manages users, along with their roles, capabilities, and meta.

$wp help user

NAME

  wp user

DESCRIPTION

  Manages users, along with their roles, capabilities, and meta.

SYNOPSIS

  wp user <command>

SUBCOMMANDS

  add-cap             Adds a capability to a user.
  add-role            Adds a role for a user.
  check-password      Checks if a user's password is valid or not.
  create              Creates a new user.
  delete              Deletes one or more users from the current site.
  generate            Generates some users.
  get                 Gets details about a user.
  import-csv          Imports users from a CSV file.
  list                Lists users.
  list-caps           Lists all capabilities for a user.
  meta                Adds, updates, deletes, and lists user custom fields.
  remove-cap          Removes a user's capability.
  remove-role         Removes a user's role.
  reset-password      Resets the password for one or more users.
  session             Destroys and lists a user's sessions.
  set-role            Sets the user role.
  spam                Marks one or more users as spam.
  term                Adds, updates, removes, and lists user terms.
  unspam              Removes one or more users from spam.
  update              Updates an existing user.

  See references for [Roles and Capabilities][1] and [WP User class][2].

  ---
  [1] https://codex.wordpress.org/Roles_and_Capabilities
  [2] https://codex.wordpress.org/Class_Reference/WP_User

EXAMPLES

    # List user IDs
    $ wp user list --field=ID
    1

    # Create a new user.
    $ wp user create bob bob@example.com --role=author
    Success: Created user 3.
    Password: k9**&I4vNH(&

    # Update an existing user.
    $ wp user update 123 --display_name=Mary --user_pass=marypass
    Success: Updated user 123.

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

wp user add-cap

wp user add-role

wp user create

$ wp help user create

NAME

  wp user create

DESCRIPTION

  Creates a new user.

SYNOPSIS

  wp user create <user-login> <user-email> [--role=<role>] [--user_pass=<password>]
  [--user_registered=<yyyy-mm-dd-hh-ii-ss>] [--display_name=<name>] [--user_nicename=<nice_name>] [--user_url=<url>]
  [--nickname=<nickname>] [--first_name=<first_name>] [--last_name=<last_name>] [--description=<description>]
  [--rich_editing=<rich_editing>] [--send-email] [--porcelain]

OPTIONS

  <user-login>
    The login of the user to create.

  <user-email>
    The email address of the user to create.

  [--role=<role>]
    The role of the user to create. Default: default role. Possible values
    include 'administrator', 'editor', 'author', 'contributor', 'subscriber'.

  [--user_pass=<password>]
    The user password. Default: randomly generated.

  [--user_registered=<yyyy-mm-dd-hh-ii-ss>]
    The date the user registered. Default: current date.

  [--display_name=<name>]
    The display name.

  [--user_nicename=<nice_name>]
    A string that contains a URL-friendly name for the user. The default is the user's username.

  [--user_url=<url>]
    A string containing the user's URL for the user's web site.

  [--nickname=<nickname>]
    The user's nickname, defaults to the user's username.

  [--first_name=<first_name>]
    The user's first name.

  [--last_name=<last_name>]
    The user's last name.

  [--description=<description>]
    A string containing content about the user.

  [--rich_editing=<rich_editing>]
    A string for whether to enable the rich editor or not. False if not empty.

  [--send-email]
    Send an email to the user with their new account details.

   Send an email to the user with their new account details.

  [--porcelain]
    Output just the new user id.

EXAMPLES

    # Create user
    $ wp user create bob bob@example.com --role=author
    Success: Created user 3.
    Password: k9**&I4vNH(&

    # Create user without showing password upon success
    $ wp user create ann ann@example.com --porcelain
    4

Voorbeeld:

cd /var/www/example.com
  #
  wp user create "Jan Jansen" jan@example.com --role=administrator --first_name="Jan" --last_name="Janden" --send-email

wp user delete

$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

Voorbeeld: Verwijder alle klant-accounts. Gooi bijbehorende content weg. Switch --yes om te bevestigen dat content verwijderd moet worden

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.

wp user generate

wp user get

wp user import-csv

wp user list

$ wp help user list

NAME

  wp user list

DESCRIPTION

  Lists users.

SYNOPSIS

  wp user list [--role=<role>] [--<field>=<value>] [--network] [--field=<field>] [--fields=<fields>]
  [--format=<format>]

  Display WordPress users based on all arguments supported by
  [WP_User_Query()][1].

  ---
  [1] https://developer.wordpress.org/reference/classes/wp_user_query/prepare_query/

OPTIONS

  [--role=<role>]
    Only display users with a certain role.

  [--<field>=<value>]
    Control output by one or more arguments of WP_User_Query().

  [--network]
    List all users in the network for multisite.

  [--field=<field>]
    Prints the value of a single field for each user.

  [--fields=<fields>]
    Limit the output to specific object fields.

  [--format=<format>]
    Render output in a particular format.
    ---
    default: table
    options:
      - table
      - csv
      - ids
      - json
      - count
      - yaml
    ---

AVAILABLE FIELDS

  These fields will be displayed by default for each user:

  * ID
  * user_login
  * display_name
  * user_email
  * user_registered
  * roles

  These fields are optionally available:

  * user_pass
  * user_nicename
  * user_url
  * user_activation_key
  * user_status
  * spam
  * deleted
  * caps
  * cap_key
  * allcaps
  * filter
  * url

EXAMPLES

    # List user IDs
    $ wp user list --field=ID
    1

    # List users with administrator role
    $ wp user list --role=administrator --format=csv
    ID,user_login,display_name,user_email,user_registered,roles
    1,supervisor,supervisor,supervisor@gmail.com,"2016-06-03 04:37:00",administrator

    # List users with only given fields
    $ wp user list --fields=display_name,user_email --format=json
    [{"display_name":"supervisor","user_email":"supervisor@gmail.com"}]

    # List users ordered by the 'last_activity' meta value.
    $ wp user list --meta_key=last_activity --orderby=meta_value_num

wp user list-caps

wp user meta

wp user remove-cap

wp user remove-role

wp user session

wp user set-role

wp user spam

wp user term

wp user unspam

wp user update

Syntaxis:

wp user update <user-id> <argument + waarde>

Admin-wachtwoord aanpassen:

wp user update 1 --user_pass=12345