bp_activity_mark_as_ham( BP_Activity_Activity $activity, string $source = 'by_a_person' )
Mark an activity item as ham.
Description
Parameters
- $activity
-
(Required) The activity item to be hammed. Passed by reference.
- $source
-
(Optional) Default is "by_a_person" (ie, a person has manually marked the activity as spam). BP core also accepts 'by_akismet'.
Default value: 'by_a_person'
Source
File: bp-activity/bp-activity-functions.php
function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) { $bp = buddypress(); $activity->is_spam = 0; // Clear the activity feed first page cache. wp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); // Clear the activity comment cache for this activity item. wp_cache_delete( $activity->id, 'bp_activity_comments' ); // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity. if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) { remove_action( 'bp_activity_before_save', array( $bp->activity->akismet, 'check_activity' ), 4 ); // Build data package for Akismet. $activity_data = BP_Akismet::build_akismet_data_package( $activity ); // Tell Akismet this is spam. $activity_data = $bp->activity->akismet->send_akismet_request( $activity_data, 'submit', 'ham' ); // Update meta. add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_ham_meta' ), 1, 1 ); } /** * Fires at the end of the process to mark an activity item as ham. * * @since BuddyPress 1.6.0 * * @param BP_Activity_Activity $activity Activity item being marked as ham. * @param string $source Source of determination of ham status. For example * "by_a_person" or "by_akismet". */ do_action( 'bp_activity_mark_as_ham', $activity, $source ); }
Changelog
Version | Description |
---|---|
BuddyPress 1.6.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.