WP-CLI Commands
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
Section titled “Command Overview”All commands use the wp bppolls namespace:
wp bppolls <command> [options]| Command | Description |
|---|---|
generate |
Generate demo poll data for testing |
clean |
Delete only the demo data generate made; members’ content is kept |
reset |
Delete all poll and survey data from the database, real and demo |
stats |
Display poll statistics and counts |
list |
List all polls with details |
Generate Demo Data
Section titled “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>] [--author=<user_id>]Options
Section titled “Options”| Option | Default | Description |
|---|---|---|
--type |
all |
Type of data to generate: all, polls, activity, or surveys |
--author |
Current WP-CLI user, else first admin | User ID to use as the poll author |
Examples
Section titled “Examples”# Generate all demo data (standalone polls, activity polls and surveys)wp bppolls generate
# Generate only standalone pollswp bppolls generate --type=polls
# Generate only BuddyPress activity pollswp bppolls generate --type=activity
# Generate only surveys (with sample responses)wp bppolls generate --type=surveys
# Generate polls as a specific userwp bppolls generate --author=5What Gets Created
Section titled “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.
Surveys: Sample surveys with their question polls and completed responses.
Each run replaces only the demo rows an earlier generate created. Members’ real polls, activity polls and surveys are never deleted, voted on or changed. Demo data made by version 5.0.1 or earlier carries no demo tag, so generate leaves it in place.
Remove Demo Data
Section titled “Remove Demo Data”Delete only the demo polls, activity polls and surveys that generate made, with their votes and responses. Members’ real polls, activity polls, surveys and votes are kept. Run this before a site goes live.
wp bppolls clean [--yes]| Option | Description |
|---|---|
--yes |
Skip the confirmation prompt |
Demo data made by version 5.0.1 or earlier carries no demo tag, so clean leaves it in place; delete it from Polls in wp-admin.
Reset Poll Data
Section titled “Reset Poll Data”Delete all poll and survey data from the database, including members’ real content, not only demo data. Use this command with caution as it permanently removes data.
wp bppolls reset [--yes]Options
Section titled “Options”| Option | Description |
|---|---|
--yes |
Skip the confirmation prompt |
Examples
Section titled “Examples”# Reset with confirmation promptwp bppolls reset
# Reset without confirmation (for scripts)wp bppolls reset --yesWhat Gets Deleted
Section titled “What Gets Deleted”- All
wbpollposts (standalone polls and survey question polls) and their_wbpoll_meta - Every BuddyPress activity that holds a poll (
bpolls_meta), with the activity itself - All
wbsurveysurveys and every survey response - All vote records (the votes table is emptied) and voter data
Always back up your database before running this command. This action is irreversible.
View Statistics
Section titled “View Statistics”Display poll statistics including counts by status and type.
wp bppolls statsOutput Example
Section titled “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: 15Use 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
Section titled “List All Polls”Display a detailed list of all polls in the system with support for multiple output formats.
wp bppolls list [--format=<format>]wp bppolls list-polls is an alias and runs the same command.
Options
Section titled “Options”| Option | Default | Description |
|---|---|---|
--format |
table |
Output format: table, json, or csv |
Examples
Section titled “Examples”# Display as a table (default)wp bppolls list
# Export as JSONwp bppolls list --format=json
# Export as CSV and save to a filewp bppolls list --format=csv > polls.csvTable Output Example
Section titled “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
Section titled “Automation Examples”Development Setup Script
Section titled “Development Setup Script”#!/bin/bash# Reset existing data and generate fresh demo contentwp bppolls reset --yeswp bppolls generatewp bppolls statsBackup Before Reset
Section titled “Backup Before Reset”#!/bin/bash# Export current polls to JSON before resettingwp bppolls list --format=json > polls-backup-$(date +%Y%m%d).jsonwp bppolls resetCI/CD Integration
Section titled “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 --yesRequirements
Section titled “Requirements”- WordPress 6.6 or later
- WP-CLI 2.0 or later
- BuddyPress (required for activity poll commands)
- WB Polls plugin must be activated
Troubleshooting
Section titled “Troubleshooting”“Command not found” error
Section titled ““Command not found” error”Ensure the plugin is activated:
wp plugin activate buddypress-pollsActivity polls skipped
Section titled “Activity polls skipped”If you see “BuddyPress is not active. Skipping activity polls,” activate BuddyPress first:
wp plugin activate buddypressUser not found error
Section titled “User not found error”Specify a valid user ID:
# List available userswp user list --fields=ID,display_name,role
# Use a specific userwp bppolls generate --author=1
