How to add BuddyPress private message link after author details

To add a BuddyPress private message link after the author details using functions.php, you can use the bp_activity_entry_meta action hook in your theme’s functions.php file or in a separate plugin file. This hook is used to display the metadata for an activity item (such as the time and date it was posted, the author, etc.).

You can use the bp_is_active function to check if the BuddyPress private messages component is active, and the bp_get_send_private_message_link function to get the private message link.

Here’s an example of how you can use these functions to add a private message link after the author details:

// Add BuddyPress private message link after author details
// More snippets at wpunplugged.com 

function my_custom_private_message_link() {
	if ( bp_is_active( 'messages' ) ) {
		// Get the private message link
		$private_message_link = bp_get_send_private_message_link();

		// Display the private message link
		echo '<span class="private-message-link">' . $private_message_link . '</span>';
	}
}
add_action( 'bp_activity_entry_meta', 'my_custom_private_message_link' );

This code will display a private message link after the author details for each activity item. The private message link will only be displayed if the BuddyPress private messages component is active.

You can customize the display of the private message link by modifying the HTML output in the echo statement. For example, you could wrap the private message link in a button element, or you could add a custom CSS class to style the link.

Share this post

You might also like...

Comment

Your email address will not be published. Required fields are marked *