BuddyPress Integration
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.
Feature 1: Activity Stream
Section titled “Feature 1: Activity Stream”When enabled (bp_activity setting), SnipShare records a BuddyPress activity item whenever a user creates a public paste.
Activity Details
Section titled “Activity Details”| 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 |
What is NOT recorded
Section titled “What is NOT recorded”- Unlisted and private pastes
- Forked pastes (handled separately)
- Anonymous pastes (user_id = 0)
Filtering Activity Display
Section titled “Filtering Activity Display”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().
oEmbed in Activity Feed
Section titled “oEmbed in Activity Feed”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.

Feature 2: Member Profile Tab
Section titled “Feature 2: Member Profile Tab”When enabled (bp_profile setting), a Pastes tab appears in each member’s BuddyPress profile at navigation position 80.
Tab Structure
Section titled “Tab Structure”/members/{username}/pastes/ → My Pastes sub-tab (default)/members/{username}/pastes/my-pastes/ → My Pastes/members/{username}/pastes/starred/ → Starred pastesMy Pastes Sub-tab
Section titled “My Pastes Sub-tab”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/

Starred Sub-tab
Section titled “Starred Sub-tab”Displays pastes the member has starred. Only active, public pastes are shown to any visitor.
Customising the Position
Section titled “Customising the Position”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 );Feature 3: Notifications
Section titled “Feature 3: Notifications”When enabled (bp_notifications setting), SnipShare sends BuddyPress notifications to paste owners.
Notification Triggers
Section titled “Notification Triggers”| 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.
Notification Format
Section titled “Notification Format”Notifications appear in the BuddyPress notification dropdown as linked text. When clicked, they take the owner to the paste page.
Component Registration
Section titled “Component Registration”SnipShare registers itself on the BuddyPress global object:
buddypress()->snipshare->notification_callback = array( $this, 'format_notification' );Notification Actions
Section titled “Notification Actions”Two component actions are used:
paste_starred- fired when a paste is starredpaste_forked- fired when a paste is forked
These are stored in the bp_notifications table with:
component_name:snipshareitem_id: paste IDsecondary_item_id: user ID who triggered the action
Developer Notes
Section titled “Developer Notes”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.

