Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 4 years ago

#6293 closed enhancement (fixed)

Support customising of activity content for custom post type activities

Reported by: rogercoathup Owned by: imath
Milestone: 2.3 Priority: normal
Severity: normal Version:
Component: Activity Keywords: has-patch
Cc:

Description

The new code for custom post type activities provides a mechanism for customising the activity action field, but doesn't provide a means to customise the activity content field.

Customising activity content requires access to the post for which the activity is being generated. I suggest this is best achieved by:

  1. passing a content callback function as a parameter when the custom post type activity tracking is registered (bp_activity_set_post_type_tracking_args), and / or
  2. providing a filter (hooked on the activity type) that allows the content to the overridden before saving

If option 1, I'm not sure if this is extendable to the register_post_type mechanism for custom post type activity tracking registration.

Attachments (1)

6293.patch (728 bytes) - added by imath 5 years ago.

Download all attachments as: .zip

Change History (7)

#1 @imath
5 years ago

Thanks for your feedback @rogercoathup

I think a good first step would be to actually include a filter in bp_activity_add(). We are using bp_parse_args() in this function without including a filter.

#2 @rogercoathup
5 years ago

agreed @imath, that sounds a simple enhancement, and even greater applicability than just custom post type activities.

@imath
5 years ago

#3 @imath
5 years ago

  • Component changed from API to Component - Activity
  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 2.3

With 6293.patch you could filter bp_before_activity_add_parse_args

#4 @r-a-y
5 years ago

  1. Would make a nice enhancement. In the meantime, you can use the existing 'bp_get_activity_content_body' filter.
  1. A new filter before saving is not necessary. Use the 'bp_activity_before_save' hook:
function my_activity_before_save( $activity ) {
    if ( 'whatever' === $activity->type ) {
        $activity->content = 'blah';
    }
}
add_action( 'bp_activity_before_save', 'my_activity_before_save' );

This ticket was mentioned in Slack in #buddypress by djpaul. View the logs.


4 years ago

#6 @imath
4 years ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 9853:

When adding an activity, allow arguments to be filtered.

bp_activity_add() is using bp_parse_args() to parse the activity arguments. Adding the third arguments to bp_parse_args() will help plugin developers to edit the activity arguments before it has been saved using the bp_before_activity_add_parse_args or bp_after_activity_add_parse_args filters.

Props rogercoathup

Fixes #6293

Note: See TracTickets for help on using tickets.