Generate all demo data (standalone polls and activity polls)
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 |
reset |
Delete all poll data from the database |
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>] [--user=<user_id>]Options
Section titled “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
Section titled “Examples”wp bppolls generate
# Generate only standalone pollswp bppolls generate --type=polls
# Generate only BuddyPress activity pollswp bppolls generate --type=activity
# Generate polls as a specific userwp bppolls generate --user=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.
The command deletes existing demo polls before creating new ones.
Reset Poll Data
Section titled “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
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
wbpollcustom post type entries - All poll-related post meta with
_wbpoll_prefix 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
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>]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 5.0 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 --user=1
