Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

  • Tom Swain
    Participant

    @visiondigitalaz

    For anyone else trying to figure this out, I didn’t find THE solution, but I did find A solution… it’s simple javascript. Wrap your notification in a div with the class “count” or whatever works for you, and hide it when its content is ‘0’.

    
    <div class="count">
    	<?php echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ); ?>
    </div>
    
    
    <script type="text/javascript">
    	//HIDE NOTIFICATION IF COUNT IS ZERO
    	let divs = document.getElementsByClassName('count');
    
    	for (let x = 0; x < divs.length; x++) {
    	    let div = divs[x];
    	    let content = div.innerHTML.trim();
    
    	    if (content == '0') {
    	        div.style.display = 'none';
    	    }
    	}
    </script>
    

    Tom Swain
    Participant

    @visiondigitalaz

    Thank you so much for your reply!

    If I’m understanding you correctly, I put the code in like this…

    
    <?php
    	$count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
    	$count = empty( $count ) ? '' : $count;
    ?>
    

    But that doesn’t seem to be working. Am I doing something wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
Skip to toolbar