public
Created

BuddyPress - add message button in members loop

  • Download Gist
gistfile1.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13
 
function filter_message_button_link( $link ) {
$link = wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_get_member_user_id() ) );
return $link;
}
 
function display_private_message_button() {
if( bp_get_member_user_id() != bp_loggedin_user_id() ) {
bp_send_message_button();
add_filter('bp_get_send_private_message_link', 'filter_message_button_link', 1, 1 );
}
}
add_action( 'bp_directory_members_item', 'display_private_message_button' );

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.