Support » Plugin: bbPress Messages » Need to replace “Send a message” with a picture!

  • Resolved akira010203



    First of all, congrats for this plugin!

    I’m trying to upgrade to the latest version because there is too many requests on the SQL DB with the older version, my hosting provider want to kick me out, hope it will be lighter with this version!

    I need to modifiy this part :

    function bbpm_prepare_contact_button($user_id) {
        $btn = array(
            'link' => null,
            'link_title' => null,
            'unread_count' => null,
            'inner_text' => null
        $user = get_userdata($user_id);
        if ( !empty($user->ID) ) {
            $m = bbpm_messages();
            if ( $m->current_user ) {
                $chat_id = $m->getPrivateSharedChat($m->current_user, $user->ID);
                if ( $chat_id ) {
                    $btn['link'] = bbpm_messages_url($chat_id, $m->current_user);
                    $btn['unread_count'] = $m->getChatUnreadCount($chat_id);
                } else {
                    global $bbpm_bases;
                    $btn['link'] = bbpm_messages_url(sprintf('%s/%d/', $bbpm_bases['with'], $user->ID), $m->current_user);
            } else {
                $btn['link'] = apply_filters(
            $btn['link_title'] = sprintf(__('Send %s a Message', BBP_MESSAGES_DOMAIN), $user->display_name);
        $btn['inner_text'] = __('Send a Message', BBP_MESSAGES_DOMAIN);
        return apply_filters('bbpm_prepare_contact_button', $btn, $user_id);

    Which is way harder than the previous version, here is my old code :

    add_filter('bbp_template_after_user_profile', function() {
    			$user_id = bbp_get_displayed_user_id();
    			global $current_user;
    			if( empty( $current_user->ID ) || !get_userdata( $user_id ) || $user_id == $current_user->ID )
    				<p>					<a href="<?php echo bbpm_messages_base( get_userdata( $user_id )->user_nicename . '/', wp_get_current_user()->ID ); ?>"><img src="/wp-includes/images/mail.png" title="Send a PM"></a>				</p>
    			echo apply_filters('bbpm_bbp_template_after_user_profile', ob_get_clean());

    Would be great if someone can help me to put a <img src="/wp-includes/images/mail.png" /> instead of the classical ” send a message”.


    • This topic was modified 2 years, 7 months ago by  akira010203.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Humm, just found out a strange button.php in the files, it solved my issue 😉

    Now I have to found out how to move back this button to the middle of the page, before some other informations, which was the case before this version.

    • This reply was modified 2 years, 7 months ago by  akira010203.
    Plugin Contributor Samuel Elh


    Hello Akira,

    Sorry for the delay.

    Yes, the file that parses the contact link is that one at /templates/button.php. to modify this file:

    1. make a directory in your child theme name it bbp-messages,
    2. copy the button.php file to this directory you just created.
    3. Add this code to your child theme’s functions file or a custom plugin:

    add_filter('bbpm_load_template_file_button.php', function(){
        return get_stylesheet_directory() . '/bbp-messages/button.php';

    The code will filter where we load the button file, from the plugin templates to the child theme’s.

    Hope that helps.


    Thanks Samuel, this way is in fact, way better for your next updates.

    I Still have a little problem with the new design of this version.

    My new button comes bellow all the user informations, it wasnt the case before.

    Do you know where I can put it back on top, just beside the user nickname ?

    The old design was :

    User logo
    my button (bbpm)
    BBP User ranking plugin

    and now :

    User logo
    BBP User ranking plugin
    my button (bbpm)

    Same for the profile page, BBP User ranking plugin comes before my button.

    Hope I was enough clear for ou to understand!

    Thanks again for your time!

    Plugin Contributor Samuel Elh


    Hello Akira,

    Sorry about the long delay to respond.

    I believe it has to do with filters priorities so you might want to try this:

    remove_action('bbp_template_after_user_profile', 'bbpm_profile_parse_contact_button');
    add_action('bbp_template_after_user_profile', 'bbpm_profile_parse_contact_button', 0);
    remove_action('bbp_theme_after_reply_author_details', 'bbpm_forums_parse_contact_button');
    add_action('bbp_theme_after_reply_author_details', 'bbpm_forums_parse_contact_button', 0);

    to prioritize bbp actions over others made by plugins.

    Let me know how it goes.


    Worked like a charm!
    Thanks again Samuel!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Need to replace “Send a message” with a picture!’ is closed to new replies.