Index: src/bp-activity/bp-activity-template.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/bp-activity/bp-activity-template.php	(date 1512426242000)
+++ src/bp-activity/bp-activity-template.php	(date 1512463698000)
@@ -3081,16 +3081,21 @@
 	 *
 	 * @since 1.2.0
 	 *
+     * @param int|null $user_id ID of the user. If null, will be used the displayed user ID
 	 *
 	 * @return string The public message link for the displayed user.
 	 */
-	function bp_get_send_public_message_link() {
+	function bp_get_send_public_message_link( $user_id = null ) {
+
+		$displayed_user_id = bp_displayed_user_id();
+
+		$user_id = ( is_null( $user_id ) ) ? bp_displayed_user_id() : absint( $user_id );
 
 		// No link if not logged in, not looking at someone else's profile.
-		if ( ! is_user_logged_in() || ! bp_is_user() || bp_is_my_profile() ) {
+		if ( ! is_user_logged_in() || ( bp_is_my_profile() && $displayed_user_id == $user_id ) ) {
 			$retval = '';
 		} else {
-			$args   = array( 'r' => bp_get_displayed_user_mentionname() );
+			$args   = array( 'r' => bp_activity_get_user_mentionname( $user_id ) );
 			$url    = add_query_arg( $args, bp_get_activity_directory_permalink() );
 			$retval = wp_nonce_url( $url );
 		}
Index: src/bp-messages/bp-messages-template.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/bp-messages/bp-messages-template.php	(date 1512426242000)
+++ src/bp-messages/bp-messages-template.php	(date 1512463698000)
@@ -1355,11 +1355,18 @@
 	/**
 	 * Generate the URL for the Private Message link in member profile headers.
 	 *
+     * @param int|null $user_id ID of the user. If null, will be used the displayed user ID
+     *
 	 * @return bool|string False on failure, otherwise the URL.
 	 */
-	function bp_get_send_private_message_link() {
+	function bp_get_send_private_message_link( $user_id = null ) {
 
-		if ( bp_is_my_profile() || ! is_user_logged_in() ) {
+		$displayed_user_id = bp_displayed_user_id();
+
+		$user_id = ( is_null( $user_id ) ) ? bp_displayed_user_id() : absint( $user_id );
+
+		// No link if not logged in, not looking at someone else's profile.
+		if ( ! is_user_logged_in() || ( bp_is_my_profile() && $displayed_user_id == $user_id ) ) {
 			return false;
 		}
 
@@ -1370,7 +1377,7 @@
 		 *
 		 * @param string $value URL for the Private Message link in member profile headers.
 		 */
-		return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_displayed_user_id() ) ) );
+		return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( $user_id ) ) );
 	}
 
 /**
@@ -1393,31 +1400,48 @@
 }
 	/**
 	 * Generate the 'Private Message' button for member profile headers.
-	 *
+     * 
+	 * @param array|string $args {
+	 *     All arguments are optional. See {@link BP_Button} for complete
+	 *     descriptions.
+	 *     @type string $id                Default: 'private_message'.
+	 *     @type string $component         Default: 'messages'.
+	 *     @type bool   $must_be_logged_in Default: true.
+	 *     @type bool   $block_self        Default: true.
+	 *     @type string $wrapper_id        Default: 'send-private-message'.
+	 *     @type string $link_href         Default: the private message link for
+	 *                                     the current member in the loop.
+	 *     @type string $link_text         Default: 'Private Message'.
+	 *     @type string $link_class        Default: 'send-message'.
+	 * }
 	 * @return string
 	 */
-	function bp_get_send_message_button() {
-		// Note: 'bp_get_send_message_button' is a legacy filter. Use
-		// 'bp_get_send_message_button_args' instead. See #4536.
-		return apply_filters( 'bp_get_send_message_button',
+	function bp_get_send_message_button( $args = '' ) {
 
-			/**
-			 * Filters the "Private Message" button for member profile headers.
-			 *
-			 * @since 1.8.0
-			 *
-			 * @param array $value See {@link BP_Button}.
-			 */
-			bp_get_button( apply_filters( 'bp_get_send_message_button_args', array(
-				'id'                => 'private_message',
-				'component'         => 'messages',
-				'must_be_logged_in' => true,
-				'block_self'        => true,
-				'wrapper_id'        => 'send-private-message',
-				'link_href'         => bp_get_send_private_message_link(),
-				'link_text'         => __( 'Private Message', 'buddypress' ),
-				'link_class'        => 'send-message',
-			) ) )
+		$r = bp_parse_args( $args, array(
+			'id'                => 'private_message',
+			'component'         => 'messages',
+			'must_be_logged_in' => true,
+			'block_self'        => true,
+			'wrapper_id'        => 'send-private-message',
+			'link_href'         => bp_get_send_private_message_link(),
+			'link_text'         => __( 'Private Message', 'buddypress' ),
+			'link_class'        => 'send-message',
+		) );
+		
+		
+		// Note: 'bp_get_send_message_button' is a legacy filter. Use
+		// 'bp_get_send_message_button_args' instead. See #4536.
+		return apply_filters( 'bp_get_send_message_button',
+
+			/**
+			 * Filters the "Private Message" button for member profile headers.
+			 *
+			 * @since 1.8.0
+			 *
+			 * @param array $value See {@link BP_Button}.
+			 */
+			bp_get_button( apply_filters( 'bp_get_send_message_button_args', $r ) )
 		);
 	}
 
