Custom messages location
To be able to implement this guide, you need to learn how to insert PHP snippets to your website.
You can find guide here: WP Beginner
Setting a custom messages location lets you integrate the plugin with any other plugin or theme as the messaging system.
To display layout of plugin at any custom place of website you can use this function:
<?php
/**
* Displaying messages in custom place
*/
echo Better_Messages()->functions->get_page();
Then point the plugin at that location with the filter below, so notification links lead to the right place:
<?php
/**
* Replacing plugin URL
*/
add_filter('bp_better_messages_page', 'overwrite_better_messages_location', 10, 2 );
function overwrite_better_messages_location( $url, $user_id ) {
return home_url( '/my-account/messages/' );
}
The filter receives the user ID as its second argument, so the URL can be per-user. On a BuddyPress site, build it from the member's profile URL through the plugin's own helper rather than calling BuddyPress directly — the helper picks bp_members_get_user_url() on current BuddyPress and falls back to the older function automatically:
function overwrite_better_messages_location( $url, $user_id ) {
return Better_Messages()->functions->bp_core_get_user_domain( $user_id ) . 'settings/messages/';
}
Removing notice about messages location in WP Admin:
add_action( 'admin_init', 'bm_remove_admin_notices' );
function bm_remove_admin_notices(){
if( ! class_exists('Better_Messages_Hooks') ) return;
remove_action( 'admin_notices', array( Better_Messages_Hooks::instance(), 'admin_notice') );
}