WB Polls provides WP-CLI commands for managing poll data, generating demo content, and viewing statistics from the command line. These commands are useful for development workflows, testing, and site administration.
Command Overview
All commands use the wp bppolls namespace:
wp bppolls <command> [options]
| Command | Description |
|---|---|
generate | Generate demo poll data for testing |
reset | Delete all poll data from the database |
stats | Display poll statistics and counts |
list | List all polls with details |
Generate Demo Data
Create sample polls for testing and demonstration purposes. This command populates your site with realistic poll data.
wp bppolls generate [--type=<type>] [--user=<user_id>]
Options
| Option | Default | Description |
|---|---|---|
--type | all | Type of data to generate: all, polls, or activity |
--user | First admin | User ID to use as the poll author |
Examples
# Generate all demo data (standalone polls and activity polls)
wp bppolls generate
# Generate only standalone polls
wp bppolls generate --type=polls
# Generate only BuddyPress activity polls
wp bppolls generate --type=activity
# Generate polls as a specific user
wp bppolls generate --user=5
What Gets Created
Standalone Polls: Text polls with various option counts, image polls with sample images, video polls with YouTube and Vimeo embeds, and audio polls. The command creates a mix of published, draft, and pending statuses with various expiration settings.
Activity Polls: Polls attached to activity stream items with both multi-select and single-select options. Activity polls are only generated when BuddyPress is active.
The command deletes existing demo polls before creating new ones.
Reset Poll Data
Delete all poll data from the database. Use this command with caution as it permanently removes data.
wp bppolls reset [--yes]
Options
| Option | Description |
|---|---|
--yes | Skip the confirmation prompt |
Examples
# Reset with confirmation prompt
wp bppolls reset
# Reset without confirmation (for scripts)
wp bppolls reset --yes
What Gets Deleted
- All
wbpollcustom post type entries - All poll-related post meta with
wbpollprefix keys - All BuddyPress activity poll meta with
bpolls_metakey - Vote records and voter data
Always back up your database before running this command. This action is irreversible.
View Statistics
Display poll statistics including counts by status and type.
wp bppolls stats
Output Example
=== BuddyPress Polls Statistics ===
Standalone Polls by Status:
Total: 25
Published: 18
Draft: 5
Pending: 2
Standalone Polls by Type:
Text: 12
Image: 6
Video: 4
Audio: 3
Activity Polls: 15
Use this command to monitor poll creation activity, audit content before a site launch, verify demo data generation, or track poll type distribution.
List All Polls
Display a detailed list of all polls in the system with support for multiple output formats.
wp bppolls list [--format=<format>]
Options
| Option | Default | Description |
|---|---|---|
--format | table | Output format: table, json, or csv |
Examples
# Display as a table (default)
wp bppolls list
# Export as JSON
wp bppolls list --format=json
# Export as CSV and save to a file
wp bppolls list --format=csv > polls.csv
Table Output Example
+-----+------------------------------------------+--------+---------+---------+---------------------+
| ID | Title | Type | Status | Options | Date |
+-----+------------------------------------------+--------+---------+---------+---------------------+
| 145 | What is your favorite programming lan... | Text | publish | 5 | 2026-01-02 10:30:00 |
| 144 | Best workspace setup? | Image | publish | 3 | 2026-01-02 09:15:00 |
| 143 | Favorite music video? | Video | draft | 4 | 2026-01-01 14:22:00 |
+-----+------------------------------------------+--------+---------+---------+---------------------+
Automation Examples
Development Setup Script
#!/bin/bash
# Reset existing data and generate fresh demo content
wp bppolls reset --yes
wp bppolls generate
wp bppolls stats
Backup Before Reset
#!/bin/bash
# Export current polls to JSON before resetting
wp bppolls list --format=json > polls-backup-$(date +%Y%m%d).json
wp bppolls reset
CI/CD Integration
jobs:
test:
steps:
- name: Generate test data
run: wp bppolls generate --type=polls
- name: Run tests
run: composer test
- name: Cleanup
run: wp bppolls reset --yes
Requirements
- WordPress 5.0 or later
- WP-CLI 2.0 or later
- BuddyPress (required for activity poll commands)
- WB Polls plugin must be activated
Troubleshooting
“Command not found” error
Ensure the plugin is activated:
wp plugin activate buddypress-polls
Activity polls skipped
If you see “BuddyPress is not active. Skipping activity polls,” activate BuddyPress first:
wp plugin activate buddypress
User not found error
Specify a valid user ID:
# List available users
wp user list --fields=ID,display_name,role
# Use a specific user
wp bppolls generate --user=1
