Skip to:
Content

BuddyPress.org

Opened 17 months ago

Last modified 12 days ago

#8293 new enhancement

Add filter to allow manipulation of recipients in message thread

Reported by: mangopeargroup Owned by:
Milestone: 10.0.0 Priority: normal
Severity: trivial Version: 5.2.0
Component: Messages Keywords: needs-patch good-first-bug
Cc:

Description

It would be quite useful to be able to manipulate the list of receipients shown on a message thread (i.e. adding additional data to array or amending the order of the list that's shown).

By adding a filter, we can manipulate the array of recipients before they're AJAX-ed to the template.

buddypress/bp-templates/bp-nouveau/includes/ajax.php
Line 460

return apply_filters( 'bp_get_user_message_threads_recipients', $thread->thread['recipients'] );

My use case is that I want to custom sort the list by user meta and I think this is the easiest, and best, way of doing so.

Change History (3)

#1 @mangopeargroup
17 months ago

Whoops! Wrong filter format. Below is the correct format (I've tested it and it works).

buddypress/bp-templates/bp-nouveau/includes/ajax.php
Line 460

$thread->thread['recipients'] = apply_filters( 'bp_get_user_message_thread_recipients', $thread->thread['recipients'] );

#2 @imath
3 weeks ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to 10.0.0

Hi @mangopeargroup

I'm fine with adding this filter, but I'd like to see a patch about it. If you need some guidance about how to build a BP patch, please have a read at https://codex.buddypress.org/participate-and-contribute/contribute-with-code/

In your patch, please make sure to include proper inline documentation, see: https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#4-hooks-actions-and-filters

#3 @espellcaste
12 days ago

I think you can use the recently added bp_messages_thread_get_recipients hook. Unless this sorting is strictly required to be in Nouveau only.

See location: https://github.com/buddypress/buddypress/blob/13e73bc821f8dc2fc9ff30d8166d3991268063ab/src/bp-messages/classes/class-bp-messages-thread.php#L334

Note: See TracTickets for help on using tickets.