BP_Akismet::build_akismet_data_package( BP_Activity_Activity $activity )
Build a data package for the Akismet service to inspect.
Description
See also
Parameters
- $activity
-
(Required) Activity item data.
Return
(array) $activity_data
Source
File: bp-activity/classes/class-bp-akismet.php
public static function build_akismet_data_package( $activity ) { $userdata = get_userdata( $activity->user_id ); $activity_data = array(); $activity_data['akismet_comment_nonce'] = 'inactive'; $activity_data['comment_author'] = $userdata->display_name; $activity_data['comment_author_email'] = $userdata->user_email; $activity_data['comment_author_url'] = bp_core_get_userlink( $userdata->ID, false, true); $activity_data['comment_content'] = $activity->content; $activity_data['comment_type'] = $activity->type; $activity_data['permalink'] = bp_activity_get_permalink( $activity->id, $activity ); $activity_data['user_ID'] = $userdata->ID; $activity_data['user_role'] = Akismet::get_user_roles( $userdata->ID ); /** * Get the nonce if the new activity was submitted through the "what's up, Paul?" form. * This helps Akismet ensure that the update was a valid form submission. */ if ( !empty( $_POST['_bp_as_nonce'] ) ) $activity_data['akismet_comment_nonce'] = wp_verify_nonce( $_POST['_bp_as_nonce'], "_bp_as_nonce_{$userdata->ID}" ) ? 'passed' : 'failed'; /** * If the new activity was a reply to an existing item, check the nonce with the activity parent ID. * This helps Akismet ensure that the update was a valid form submission. */ elseif ( !empty( $activity->secondary_item_id ) && !empty( $_POST['_bp_as_nonce_' . $activity->secondary_item_id] ) ) $activity_data['akismet_comment_nonce'] = wp_verify_nonce( $_POST["_bp_as_nonce_{$activity->secondary_item_id}"], "_bp_as_nonce_{$userdata->ID}_{$activity->secondary_item_id}" ) ? 'passed' : 'failed'; /** * Filters activity data before being sent to Akismet to inspect. * * @since BuddyPress 1.6.0 * * @param array $activity_data Array of activity data for Akismet to inspect. * @param BP_Activity_Activity $activity Activity item data. */ return apply_filters( 'bp_akismet_build_akismet_data_package', $activity_data, $activity ); }
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.