Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 5 years ago

#6794 closed idea (fixed)

Add Filter for bp_activity_get_activity_id args

Reported by: danbrellis Owned by: boonebgorges
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.4.0
Component: Activity Keywords:
Cc:

Description

So the bp_activity_get_activity_id() in bp-activity/bp-activity-functions.php takes an $args array and then gets an activity id using BP_Activity_Activity::get_id().

The returned id is filtered using bp_activity_get_activity_id, but this only filters the id and doesn't include the $args array or any other information for a function to use that is hooking to it.

I don't see the point in filtering the returned activity id if you don't have any context. I think that (at the least) the return should include the $args, like so:

return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id(
  $r['user_id'],
  $r['component'],
  $r['type'],
  $r['item_id'],
  $r['secondary_item_id'],
  $r['action'],
  $r['content'],
  $r['date_recorded']
), $args );

Ideally though, we should be able to hook into a filter to change the $args before it's sent to get_id(). Something like this would make sense when $args is being parsed to $r:

$r = bp_parse_args( apply_filters('bp_activity_get_activity_id_args', $args), array(
  'user_id'           => false,
  'component'         => false,
  'type'              => false,
  'item_id'           => false,
  'secondary_item_id' => false,
  'action'            => false,
  'content'           => false,
  'date_recorded'     => false,
) );

Change History (3)

#1 @henry.wright
5 years ago

I'm also wondering why it's necessary to filter the returned value of BP_Activity_Activity::get_id(). Maybe there's a reason?

#2 @boonebgorges
5 years ago

  • Milestone changed from Awaiting Review to 2.5

@danbrellis Thanks for the ticket! Good call.

@henry.wright Who knows what people do with these filters? But this one is here, so we have to keep it.

#3 @boonebgorges
5 years ago

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

In 10428:

Pass function args to bp_activity_get_activity_id filter.

These arguments give better context for filter callbacks.

Props danbrellis.
Fixes #6794.

Note: See TracTickets for help on using tickets.