Skip to:
Content
Pages
Categories
Search
Top
Bottom

bp_get_total_unread_messages_count broken and no longer works


  • jameshh93
    Participant

    @jameshh93

    I have been using this code to echo out a bubble for my header however it used to work flawlessly but now it just gives me ” Fatal error: Call to undefined function bp_get_total_unread_messages_count() in C:\Program Files (x86)\Ampps\www\retaggr101\wp-content\themes\twentysixteen\header.php on line 167″

    which kind of makes no sense at all.

    
    		              <?php 
    					  
    					            $count = bp_get_total_unread_messages_count( bp_loggedin_user_id() );
                                           if ( $count > 0 ) {
                                        echo '<div class="site-header-user-notifcations-bubble">'; echo $count; echo '</div>';
                                        } else {
                                       // The notif count is 0.
                                            }
    					  
    					  
    					  ?>

    espcially when this code works

     <?php 
    					  
    					            $count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
                                           if ( $count > 0 ) {
                                        echo '<div class="site-header-user-notifcations-bubble">'; echo $count; echo '</div>';
                                        } else {
                                       // The notif count is 0.
                                            }
    					  
    					  
    					  ?>
Viewing 2 replies - 1 through 2 (of 2 total)

  • jameshh93
    Participant

    @jameshh93

    Wait it seems this was caused by me not setting friend connections and private message in buddypress settings..


    r-a-y
    Keymaster

    @r-a-y

    If you are going to be using functions from BP components, you should check if that component is active before using that function.

    For example:

    if ( bp_is_active( 'messages' ) ) {
        $count = bp_get_total_unread_messages_count( bp_loggedin_user_id() );
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar