Skip to:
Content
Pages
Categories
Search
Top
Bottom

recent activity info outside the forum

  • @regnalf

    Participant

    I know there is a widget to show somewhere on the page if there is new activity in the forums. But is there a possibility (maybe a shortcode?) to show only an icon when there is new activity in any forum? Or better yet an info with the number of new posts?

Viewing 1 replies (of 1 total)
  • @regnalf

    Participant

    as no one answer this, i tried it by myself. i found a function in bbp-style-pack plugin for that.

    if (function_exists('bsp_is_forum_unread_amount'))
    {
    	
    	add_shortcode( 'bbp_count_new', 'bbpress_count_new' );
    	function bbpress_count_new( $atts )
    	{
    		
    		$output = "";
    		$count_new = 0;
    		
    
    		$query_foren = new WP_Query(array( 'post_type' => 'forum' ));
    		
    		
    		while($query_foren->have_posts())
    		{
    			$query_foren->the_post();
    			
    			$post_id = get_the_id();
    			
    			$bbp_forum_privategroups = get_post_meta( $post_id, '_private_group');			
    			$bbp_user_privategroups = preg_split('/\*/', get_user_meta (get_current_user_id(), 'private_group', true), -1, PREG_SPLIT_NO_EMPTY);
    			
    			if ( count( $bbp_forum_privategroups ) == 0 )
    			{
    				$amount_unr = bsp_is_forum_unread_amount( $post_id );
    				$count_new += $amount_unr->amount;
    			}
    			else
    			{
    				if ( count( array_intersect( $bbp_forum_privategroups, $bbp_user_privategroups )) > 0 )
    				{
    					$amount_unr = bsp_is_forum_unread_amount( $post_id );
    					$count_new += $amount_unr->amount;
    				}
    			}
    		}
    		
    		if ($count_new > 0 )
    		{
    			ob_start();
    			?><span style="margin-left: 0.3rem; font-size: 0.8rem; padding: 0.4rem;"> <?php echo($count_new); ?></span><?php
    			$output = ob_get_contents();
    			ob_end_clean();
    		}
    		
    		return $output;
    	}
    
    	
    }

    i hope i didn’t oversee something, because it is also combined with private forum groups!

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar