Hooks and Filters
SnipShare provides 2 filters, 11 lifecycle action hooks, and 21 template hooks so you can customise paste behaviour, react to events, and inject content anywhere in the front-end templates - without editing core files.
Filters
Section titled “Filters”snipshare_before_create_paste
Section titled “snipshare_before_create_paste”Fires immediately before a new paste is inserted into the database. Use this to validate, modify, or augment paste data.
Signature:
$data = apply_filters( 'snipshare_before_create_paste', $data );Parameters:
| Param | Type | Description |
|---|---|---|
$data |
array | Paste data array before INSERT. Keys: user_id, title, description, visibility, status, password_hash, burn_after_read, expires_at, share_hash, file_count |
Return: Modified $data array.
Example - force all new pastes to be unlisted:
add_filter( 'snipshare_before_create_paste', function( $data ) { $data['visibility'] = 'unlisted'; return $data;} );snipshare_paste_query_args
Section titled “snipshare_paste_query_args”Fires inside SnipShare_Paste::query() before the SQL query is built. Use this to modify query arguments - add custom filters, override defaults, or restrict results.
Signature:
$args = apply_filters( 'snipshare_paste_query_args', $args );Parameters:
| Param | Type | Description |
|---|---|---|
$args |
array | Query args array. Keys: user_id, visibility, status, language, tag, search, per_page, page, orderby, order |
Return: Modified $args array.
Example - exclude a specific user’s pastes from all public queries:
add_filter( 'snipshare_paste_query_args', function( $args ) { // Exclude user ID 5 from all queries if ( empty( $args['user_id'] ) ) { $args['exclude_user'] = 5; // you'd also need to handle this in a custom query } return $args;} );Actions
Section titled “Actions”snipshare_paste_created
Section titled “snipshare_paste_created”Fires after a new paste is successfully inserted.
do_action( 'snipshare_paste_created', $paste_id, $data );| Param | Type | Description |
|---|---|---|
$paste_id |
int | ID of the newly created paste |
$data |
array | The raw data array passed to SnipShare_Paste::create() |
Use case: Send notifications, update external indexes, trigger webhooks.
snipshare_paste_updated
Section titled “snipshare_paste_updated”Fires after a paste is successfully updated.
do_action( 'snipshare_paste_updated', $paste_id, $data );| Param | Type | Description |
|---|---|---|
$paste_id |
int | ID of the updated paste |
$data |
array | The data array passed to the update call |
snipshare_paste_trashed
Section titled “snipshare_paste_trashed”Fires after a paste’s status is set to trashed.
do_action( 'snipshare_paste_trashed', $paste_id );snipshare_paste_deleted
Section titled “snipshare_paste_deleted”Fires after a paste is permanently deleted from the database.
do_action( 'snipshare_paste_deleted', $paste_id );Note: At this point the paste row and all related records (files, revisions, tags, stars) have already been deleted.
snipshare_paste_forked
Section titled “snipshare_paste_forked”Fires after a paste is forked.
do_action( 'snipshare_paste_forked', $fork_id, $original_paste_id, $user_id );| Param | Type | Description |
|---|---|---|
$fork_id |
int | ID of the newly created fork |
$original_paste_id |
int | ID of the paste that was forked |
$user_id |
int | ID of the user who performed the fork |
Use case: BuddyPress fork notification (built-in). Updating fork counts on external systems.
snipshare_paste_starred
Section titled “snipshare_paste_starred”Fires after a user stars a paste (toggle on).
do_action( 'snipshare_paste_starred', $paste_id, $user_id );Use case: BuddyPress star notification (built-in). Gamification points.
snipshare_paste_unstarred
Section titled “snipshare_paste_unstarred”Fires after a user removes their star from a paste (toggle off).
do_action( 'snipshare_paste_unstarred', $paste_id, $user_id );snipshare_paste_reported
Section titled “snipshare_paste_reported”Fires after a user submits a report.
do_action( 'snipshare_paste_reported', $report_id, $paste_id, $reporter_id );| Param | Type | Description |
|---|---|---|
$report_id |
int | ID of the new report record |
$paste_id |
int | ID of the reported paste |
$reporter_id |
int | WP user ID of the reporter |
Use case: Email notification to admins when a new report is filed.
add_action( 'snipshare_paste_reported', function( $report_id, $paste_id, $reporter_id ) { wp_mail( get_option( 'admin_email' ), 'New paste reported', "Paste ID {$paste_id} was reported. View it at: " . admin_url( 'admin.php?page=snipshare-moderation' ) );}, 10, 3 );snipshare_report_reviewed
Section titled “snipshare_report_reviewed”Fires after an admin reviews a report.
do_action( 'snipshare_report_reviewed', $report_id, $action );| Param | Type | Description |
|---|---|---|
$report_id |
int | ID of the reviewed report |
$action |
string | reviewed or dismissed |
snipshare_collection_created
Section titled “snipshare_collection_created”Fires after a new collection is created.
do_action( 'snipshare_collection_created', $collection_id, $data );snipshare_paste_added_to_collection
Section titled “snipshare_paste_added_to_collection”Fires after a paste is added to a collection.
do_action( 'snipshare_paste_added_to_collection', $collection_id, $paste_id );Template Actions
Section titled “Template Actions”SnipShare also fires template hooks in all front-end templates for injecting custom content:
| Hook | Location |
|---|---|
snipshare_before_archive |
Before paste archive content |
snipshare_after_archive |
After paste archive content |
snipshare_before_paste_loop |
Before paste loop in archive |
snipshare_after_paste_loop |
After paste loop in archive |
snipshare_before_paste_card |
Before each paste card (receives $paste) |
snipshare_after_paste_card |
After each paste card (receives $paste) |
snipshare_before_single_paste |
Before single paste view (receives $paste) |
snipshare_after_single_paste |
After single paste view (receives $paste) |
snipshare_before_paste_files |
Before file tabs on single view (receives $paste) |
snipshare_after_paste_files |
After file tabs on single view (receives $paste) |
snipshare_before_paste_form |
Before create/edit form |
snipshare_after_paste_form |
After create/edit form |
snipshare_paste_form_fields |
Inside form - add custom fields |
snipshare_before_user_profile |
Before user profile content (receives $profile_user) |
snipshare_after_user_profile |
After user profile content (receives $profile_user) |
snipshare_before_collection |
Before collection view (receives $collection) |
snipshare_after_collection |
After collection view (receives $collection) |
snipshare_before_diff |
Before diff view (receives $paste) |
snipshare_after_diff |
After diff view (receives $paste) |
snipshare_before_embed |
Before embed view (receives $paste) |
snipshare_after_embed |
After embed view (receives $paste) |

