Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add user report button in message thread.
/**
* Add block/unblock button on single message thread.
*/
function buddydev_show_user_report_button_on_message_thread() {
// only message involving single user can be blocked.
if ( ! function_exists( 'bpmts_report_button' ) || ! bp_is_my_profile() ) {
return;
}
global $thread_template;
if ( ! $thread_template ) {
return;
}
$recipients = wp_list_pluck( $thread_template->thread->recipients, 'user_id' );
if ( empty( $recipients ) ) {
return;
}
$my_id = get_current_user_id();
$other_id = 0;
foreach ( $recipients as $user_id ) {
if ( $user_id != $my_id ) {
$other_id = $user_id;
break;
}
}
if ( ! $other_id ) {
return;
}
bpmts_report_button(
array(
'item_id' => $other_id,
'item_type' => 'user',
'context' => 'bp_message_screen',
'context_id' => bp_displayed_user_id(),
)
);
}
add_action( 'bp_after_message_thread_recipients', 'buddydev_show_user_report_button_on_message_thread' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.