Skip to:
Content

BuddyPress.org

Opened 4 years ago

Closed 3 years ago

#8293 closed enhancement (worksforme)

Add filter to allow manipulation of recipients in message thread

Reported by: mangopeargroup's profile mangopeargroup Owned by:
Milestone: Priority: normal
Severity: trivial Version: 5.2.0
Component: Messages Keywords:
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 (4)

#1 @mangopeargroup
4 years 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 years 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
3 years 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

#4 @imath
3 years ago

  • Keywords needs-patch good-first-bug removed
  • Milestone 10.0.0 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Awesome, thanks for your input @espellcaste. Let's close this ticket.

Note: See TracTickets for help on using tickets.