Red Box/Bubble with new message noifacation buddypress

Hi

On the following page https://ohbother.forumite.co.uk/forums just above the forum are 3 buttons. I would like to add a fourth red button with the word Messages and the number of unread messages. I have spent 2 hours on your new and very poor chat support this morning and achieved nothing and dont want to go through that again and am on the verge of canceling my subscription after the ordeal. I have granted access to my site so you can investigate further.

Thankyou.

  • Adam Czajczyk
    • Support Gorilla

    Hello Lee,

    I hope you’re well today and thank you for your question!

    You can display the number of BuddyPress messages anywhere on your site using following code:

    <?php

    function wpmu_bp_messages_counter() {
    global $bp;

    $hmag_inbox_count = messages_get_unread_count();

    return '<span class="custom-bp-msg-count">' . $hmag_inbox_count . '</span>';
    }
    add_shortcode('bp_msg_count','wpmu_bp_messages_counter');

    1. Create an MU plugin:

    – create an empty file with a .php extension (e.g. “bp-messages-counter.php”:wink:

    – copy and paste that code inside it using a “clean text” editor (such as e.g. Notepad++, Sublime or similar)

    – upload the file to the “/wp-content/mu-plugins” folder of your site; if there’s no “mu-plugins” folder inside “wp-content” folder, just create one

    2. Call the code on your site:

    – you can use this shortcode anywhere on your site (posts/pages)

    [bp_msg_count]

    – you can use this shortcode in your template files like this:

    <?php echo do_shortcode('[bp_msg_count]'); ?>

    – or you can call the function directly anywhere in theme files like this:

    <?php echo wpmu_bp_messages_counter(); ?>

    That being said, you can use that code (the second or third way) in your forum’s template file and it should show the number of messages there. You can also further style the way that counter looks by adding custom styles for

    .custom-bp-msg-count

    class.

    If you have any additional questions, let me know please.

    Kind regards,

    Adam

  • Predrag Dubajic
    • Support

    Hi Mwale,

    I had a look at this chat from back then and it turned out that Lee was using a page builder to create specific page and needed help with embedding the code in that page in a certain element.

    So it was quite a specific setup.

    Could you start a new thread about this with more information of the setup you are using and where exactly you want to display this and we will check this further for you.

    Best regards,

    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.