bp_blogs_publish_post_activity_meta( int $activity_id, WP_Post $post, array $args )
Record activity metadata about a published blog post.
Description
Parameters
- $activity_id
-
(Required) ID of the activity item.
- $post
-
(Required) Post object.
- $args
-
(Required) Array of arguments.
Source
File: bp-blogs/bp-blogs-functions.php
function bp_blogs_publish_post_activity_meta( $activity_id, $post, $args ) {
if ( empty( $activity_id ) || !in_array( $post->post_type, bp_core_get_active_custom_post_type_feed() ) ) {
return;
}
bp_activity_update_meta( $activity_id, 'post_title', $post->post_title );
if ( ! empty( $args['post_url'] ) ) {
$post_permalink = $args['post_url'];
} else {
$post_permalink = $post->guid;
}
bp_activity_update_meta( $activity_id, 'post_url', $post_permalink );
$args = array(
'name' => $post->post_type
);
$output = 'objects'; // names or objects
$cu_post_types = get_post_types( $args, $output );
foreach ( $cu_post_types as $cu ) {
$singular_label_name = strtolower( $cu->labels->singular_name );
}
$admin_filters = 'New '.$singular_label_name.' published';
bp_activity_update_meta( $activity_id, 'admin_filters', $admin_filters );
// Update the blog's last activity.
bp_blogs_update_blogmeta( $args['item_id'], 'last_activity', bp_core_current_time() );
/**
* Fires after BuddyPress has recorded metadata about a published blog post.
*
* @since BuddyPress 1.0.0
*
* @param int $ID ID of the blog post being recorded.
* @param WP_Post $post WP_Post object for the current blog post.
* @param string $value ID of the user associated with the current blog post.
*/
do_action( 'bp_blogs_new_blog_post', $post->ID, $post, $args['user_id'] );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.2.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.