You can’t overload a core BP function.
The function you’re referring to has a filter hook.
So in bp-custom.php, you could do this:
function manu_bp_message_thread_to( $recipients ) {
// $recipients is a comma-separated string of user links
// for example: <a href="http://yoursite/members/manu/" title="Manu">Manu</a>
// adjust as necessary and return
return $recipients;
}
add_filter('bp_message_thread_to', 'manu_bp_message_thread_to', 20, 1);
@shanebp
Many thanks, I was able to remove the sender from the list of recipients with this custom function :
function manu_bp_message_thread_to( $recipients ) {
global $messages_template;
foreach( (array) $messages_template->thread->recipients as $object ) {
if ( (int) $object->user_id !== bp_loggedin_user_id() ) {
$sender_links[] = bp_core_get_userlink( $object->user_id );
}
}
$recipients = implode( ', ', (array)$sender_links );
return $recipients;
}
add_filter('bp_message_thread_to', 'manu_bp_message_thread_to', 20, 1);
Also now, I better understand the logic, thanks.
Congrats on the solution.
However, rather that recreate $recipients, you should be able to do a simple string operation on it. Something like:
function manu_bp_message_thread_to( $recipients ) {
$my_link = bp_core_get_userlink( bp_loggedin_user_id() ) . ',';
$recipients = str_replace($my_link, '', $recipients);
return $recipients;
}
add_filter('bp_message_thread_to', 'manu_bp_message_thread_to', 20, 1);