WP CLI Commands

The WP-Members Security extension adds a number of subcommands to the wp mem command.

settings

This command will list the primary plugin settings, showing what is enabled and what is not enabled. Use the disable or enable commands to enable or disable a given command.

To list settings, use the following command:

wp mem sec settings

To enable/disable a setting, use the --enable=<option> or --disable=<option> subcommands. For example, to enable login lockout (which is option login_lockout), use the following command:

wp mem sec settings --enable=login_lockout

sessions

Handles various options for user sessions. Can list all sessions with the get subcommand. Can get sessions by user with wp mem sec sessions list --id=123 (where 123 is the user ID) or get all sessions with wp mem sec sessions list --all

The sessions command can search for a given session by username or email address (or a sub-string). For example, search for “mike” would return all usernames and emails that contain “mike”:

wp mem sec sessions search mike

The sessions command has subcommands to destroy a given session by ID:

wp mem sec sessions destroy --id=123

failed_logins

The failed_logins command can list all failed logins:

wp mem sec failed_logins list --all

It can also search for a specific username in the list:

wp mem sec failed_logins search myuser

You can page through the list with the page argument:

wp mem sec failed_logins list --page=2

Depending on your viewport, you may want to change the number of results in the default list (20) to more or less. For example, you can view 10 users per page of the list as follows:

wp mem sec failed_logins list --per_page=10

Add the --page argument to page through your custom per_page results:

wp mem sec failed_logins list --per_page=10 --page=2

lockouts

The lockouts command allows you to list and search user lockouts.

To list all lockouts, use the list subcommand:

wp mem sec lockouts list

Display “all” or “current” lockouts:

  • wp mem sec lockouts list --all
  • wp mem sec lockouts list --current

Search lockouts by username (default):

wp mem sec lockouts search someusername

Search lockouts by email (note: currently must be complete email of the user):

wp mem sec lockouts search email@example.com

Clear a lockout for a user by lockout ID (not user ID). The lockout ID displays in the results table of lockout list or search. Example where “123” is the lockout ID:

wp mem sec clear_lock 123

Leave a Reply