Skip to content

BuddyPress Integration

SnipShare overviewPremiumGet SnipShare →

SnipShare integrates with BuddyPress to bring code sharing into your community’s activity feed, member profiles, and notification system.

Activation: Integration loads automatically when class_exists('BuddyPress') is true. No manual activation needed.

Configuration: All features are individually toggled in SnipShare → Settings → Integrations.


When enabled (bp_activity setting), SnipShare records a BuddyPress activity item whenever a user creates a public paste.

Property Value
Component snipshare
Type new_paste
Action “{User} shared a new code paste: {Paste Title}”
Content Paste description (trimmed to 30 words)
Primary link Paste frontend URL
Item ID Paste ID
  • Unlisted and private pastes
  • Forked pastes (handled separately)
  • Anonymous pastes (user_id = 0)

BuddyPress activity items from SnipShare appear in:

  • The sitewide activity stream
  • The member’s profile activity tab

Users can filter to “Pastes” in the activity stream using the “Pastes” filter label registered with bp_activity_set_action().

Paste URLs pasted into BuddyPress activity updates are automatically resolved to inline code viewers via the SnipShare oEmbed provider. This hooks into bp_get_activity_content_body to replace paste URLs with embedded iframes.

BuddyPress activity feed with embedded paste


When enabled (bp_profile setting), a Pastes tab appears in each member’s BuddyPress profile at navigation position 80.

/members/{username}/pastes/ → My Pastes sub-tab (default)
/members/{username}/pastes/my-pastes/ → My Pastes
/members/{username}/pastes/starred/ → Starred pastes

Displays the member’s pastes:

  • Profile owner sees all statuses (public, unlisted, private) for active pastes
  • Other visitors see only public pastes
  • Profile owner sees a + Add Snip button linking to /pastes/create/

BuddyPress member profile Pastes tab

Displays pastes the member has starred. Only active, public pastes are shown to any visitor.

To change the tab’s position in the BP navigation:

add_action( 'bp_setup_nav', function() {
// The tab is registered at position 80.
// Override the position via bp_core_new_nav_item filters if needed.
}, 5 );

When enabled (bp_notifications setting), SnipShare sends BuddyPress notifications to paste owners.

Event Notification
Another user stars your paste “{User} starred your paste ”{Title}“”
Another user forks your paste “{User} forked your paste ”{Title}“”

Self-notifications are never sent - starring or forking your own paste does not generate a notification.

Notifications appear in the BuddyPress notification dropdown as linked text. When clicked, they take the owner to the paste page.

SnipShare registers itself on the BuddyPress global object:

buddypress()->snipshare->notification_callback = array( $this, 'format_notification' );

Two component actions are used:

  • paste_starred - fired when a paste is starred
  • paste_forked - fired when a paste is forked

These are stored in the bp_notifications table with:

  • component_name: snipshare
  • item_id: paste ID
  • secondary_item_id: user ID who triggered the action

The BuddyPress integration class is SnipShare_BuddyPress (integrations/class-snipshare-buddypress.php). All hooks are registered externally by the loader:

$this->loader->add_action( 'bp_register_activity_actions', $bp, 'register_activity' );
$this->loader->add_action( 'bp_setup_nav', $bp, 'register_profile_tab' );
$this->loader->add_action( 'bp_setup_globals', $bp, 'register_notification' );
$this->loader->add_action( 'bp_init', $bp, 'enable_autoembed' );

Activity and notification recording is triggered by the snipshare_paste_created, snipshare_paste_starred, and snipshare_paste_forked action hooks from the core paste/star classes.