WP CLI Commands

Version 2.0.3 of the Invite Codes extension adds commands to the WP CLI interface.  These can be used for listing, managing, and editing existing codes, or adding new codes.  You can also add codes in bulk.

Get

The get command allows you to get a specific invite code or to get all codes.

Usage

The command wp mem ic get all will retrieve all existing codes in a list.

To get information about a specific code, specify the code in the command.  For example, to retrieve information about the “MyCode” invite code, use wp mem ic get MyCode.

Add

Adding codes can be done quickly if you want a random code value, or you can specify any or all of the attributes of an invitation code.  Any attributes left undefined will be set as a default value.

--code specifies the code name. Default: random value.

--desc specifies the description of the code.  Wrap the value in quotes if there are spaces (i.e. --desc="My code description")  Default: null.

--uses_remaining if the code is not unlimited, specify the number of uses. Default: null.

--bulk can set up bulk codes in a hurry.  Specify number of codes to create. Use code attributes above to specify specifics. Default: random code names.

--code_prefix used with --bulk attribute, specifies a prefix to all randomly generated code values. Default: off.

Usage

wp mem ic add will add a random code with default settings.

Example using attributes: wp mem ic add --code=MySpecialCode --desc="A special invite code" --uses_remaining=10 This would create “MySpecialCode” with the set description, available to be used 10 times.

Example of creating 10 bulk codes with a specified prefix: wp mem ic add --bulk=10 --code_prefix=Special --desc="Codes added in bulk". This would create 10 random codes prefixed by “Special” with the description “Codes added in bulk”.

Deactivate

Deactivates a specified code.

wp mem ic deactivate MySpecialCode would deactivate the “MySpecialCode” invite code.

Delete

Deletes a specified code.

wp mem ic delete MySpecialCode would delete the “MySpecialCode” invite code.