Skip to content

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.

All commands use the wp bppolls namespace:

Terminal window
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

Create sample polls for testing and demonstration purposes. This command populates your site with realistic poll data.

Terminal window
wp bppolls generate [--type=<type>] [--user=<user_id>]
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
Terminal window
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

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.

Delete all poll data from the database. Use this command with caution as it permanently removes data.

Terminal window
wp bppolls reset [--yes]
Option Description
--yes Skip the confirmation prompt
Terminal window
# Reset with confirmation prompt
wp bppolls reset
# Reset without confirmation (for scripts)
wp bppolls reset --yes
  • All wbpoll custom post type entries
  • All poll-related post meta with _wbpoll_ prefix keys
  • All BuddyPress activity poll meta with bpolls_meta key
  • Vote records and voter data

Always back up your database before running this command. This action is irreversible.

Display poll statistics including counts by status and type.

Terminal window
wp bppolls stats
=== 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.

Display a detailed list of all polls in the system with support for multiple output formats.

Terminal window
wp bppolls list [--format=<format>]
Option Default Description
--format table Output format: table, json, or csv
Terminal window
# 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
+-----+------------------------------------------+--------+---------+---------+---------------------+
| 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 |
+-----+------------------------------------------+--------+---------+---------+---------------------+
#!/bin/bash
# Reset existing data and generate fresh demo content
wp bppolls reset --yes
wp bppolls generate
wp bppolls stats
#!/bin/bash
# Export current polls to JSON before resetting
wp bppolls list --format=json > polls-backup-$(date +%Y%m%d).json
wp bppolls reset
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
  • WordPress 5.0 or later
  • WP-CLI 2.0 or later
  • BuddyPress (required for activity poll commands)
  • WB Polls plugin must be activated

Ensure the plugin is activated:

Terminal window
wp plugin activate buddypress-polls

If you see “BuddyPress is not active. Skipping activity polls,” activate BuddyPress first:

Terminal window
wp plugin activate buddypress

Specify a valid user ID:

Terminal window
# List available users
wp user list --fields=ID,display_name,role
# Use a specific user
wp bppolls generate --user=1