Skip to content

WP-CLI Commands

The plugin registers a wp bpsp command family for managing sticky posts from the shell. It is useful for bulk pin operations, migrations, cron debugging, and quick status checks.

All commands live in includes/class-bpsp-cli-command.php under the BPSP_CLI_Command class, registered as wp bpsp.


Terminal window
# Pin sitewide as administrator
wp bpsp pin 123 --scope=sitewide --as=admin
# Pin to a member's personal profile stream
wp bpsp pin 456 --scope=personal --user=5 --as=user
# Pin inside a specific group
wp bpsp pin 789 --scope=group --group=10 --as=admin

Flags:

Flag Values Required Notes
--scope sitewide, personal, group yes Which stream to pin into
--as admin, user no (default: admin) Decides which quota applies
--user integer when scope=personal Profile owner’s user ID
--group integer when scope=group Group ID

Quota enforcement runs through the shared bpsp_check_pin_quota() helper — CLI cannot bypass the cap configured on the Permissions tab.


Terminal window
wp bpsp unpin 123 --scope=sitewide
wp bpsp unpin 456 --scope=personal --user=5
wp bpsp unpin 789 --scope=group --group=10

Flags:

Flag Values Required Notes
--scope sitewide, personal, group yes Which stream to unpin from
--as admin, user no (default: admin) Role context for storage lookup
--user integer when scope=personal Profile owner’s user ID
--group integer when scope=group Group ID

Terminal window
# All pins across all scopes
wp bpsp list
# Filtered by scope
wp bpsp list --scope=sitewide
wp bpsp list --scope=personal --user=5
wp bpsp list --scope=group --group=10
# Output formats
wp bpsp list --format=json
wp bpsp list --format=csv
wp bpsp list --format=count
wp bpsp list --format=ids

--format=ids outputs a space-separated list, useful for piping:

Terminal window
# Fetch the full activity object for every sitewide pin
wp bpsp list --scope=sitewide --format=ids | xargs -n1 wp bp activity get

Bulk-pin activities that carry a custom meta key

Terminal window
wp bp activity list --meta_key=is_announcement --field=id \
| xargs -I {} wp bpsp pin {} --scope=sitewide --as=admin

Check that the expiration cron is scheduled

Terminal window
wp cron event list --hook=bpsp_check_expired_sticky_posts

bpsp_check_expired_sticky_posts is the hook registered in includes/bpsp-expiration.php. On sites that have completed the DB migration, a second variant bpsp_check_expired_sticky_posts_db also runs hourly and is registered in includes/bpsp-functions-wrapper.php.

Manually trigger one round of expiry checks

Terminal window
wp cron event run bpsp_check_expired_sticky_posts

Remove all sitewide pins that belong to deleted activities

Terminal window
for id in $( wp bpsp list --scope=sitewide --format=ids ); do
wp bp activity exists $id || wp bpsp unpin $id --scope=sitewide
done

wp bpsp pin and wp bpsp unpin call the same bpsp_add_sticky_post() and bpsp_delete_sticky_post() functions as the REST API and the browser frontend. This means every documented action hook fires normally: bpsp_after_pin_post, bpsp_user_pinned_activity, milestone hooks, and activity log entries are all written. Gamification integrations (GamiPress, myCRED, etc.) respond to CLI writes exactly as they respond to browser writes.