Only show info from network blogs who are supporters

I'd like to be able to only show info from Supporter blogs in such widgets as latest network posts, is this possible?

  • DavidM

    Hi Joe,

    I think that's definitely doable, though I'm not sure how it would be done using the BuddyPress recent posts widget. The following should work if you're using Post Indexer along with the Recent Global Posts Widget though.

    Lines 101 to 118 of widget-recent-global-posts.php should read as follows:

    foreach ($posts as $post){
    	echo '<li>';
    	if ( $recentglobalpostsavatars == 'show' ) {
    		echo '<a href="' . $post['post_permalink'] . '">' . get_avatar( $post['post_author'], $recentglobalpostsavatarsize, '' ) . '</a>';
    		echo ' ';
    	}
    	if ( $recentglobalpostsdisplay == 'title_content' ) {
    		echo '<a href="' . $post['post_permalink'] . '">' . substr( $post['post_title'], 0, $recentglobalpoststitlecharacters ) . '</a>';
    		echo '<br />';
    		echo substr( strip_tags( $post['post_content'] ), 0, $recentglobalpostscontentcharacters );
    	} else if ( $recentglobalpostsdisplay == 'title' ) {
    		echo '<a href="' . $post['post_permalink'] . '">' . substr( $post['post_title'], 0, $recentglobalpoststitlecharacters ) . '</a>';
    	} else if ( $recentglobalpostsdisplay == 'content' ) {
    		echo substr( strip_tags( $post['post_content'] ), 0, $recentglobalpostscontentcharacters );
    		echo ' (<a href="' . $post['post_permalink'] . '">' . __('More') . '</a>)';
    	}
    	echo '</li>';
    }

    You can replace all of that with the following:

    foreach ($posts as $post){
    	if ( is_supporter( $post['blog_id'] ) ){
    		echo '<li>';
    		if ( $recentglobalpostsavatars == 'show' ) {
    			echo '<a href="' . $post['post_permalink'] . '">' . get_avatar( $post['post_author'], $recentglobalpostsavatarsize, '' ) . '</a>';
    			echo ' ';
    		}
    		if ( $recentglobalpostsdisplay == 'title_content' ) {
    			echo '<a href="' . $post['post_permalink'] . '">' . substr( $post['post_title'], 0, $recentglobalpoststitlecharacters ) . '</a>';
    			echo '<br />';
    			echo substr( strip_tags( $post['post_content'] ), 0, $recentglobalpostscontentcharacters );
    		} else if ( $recentglobalpostsdisplay == 'title' ) {
    			echo '<a href="' . $post['post_permalink'] . '">' . substr( $post['post_title'], 0, $recentglobalpoststitlecharacters ) . '</a>';
    		} else if ( $recentglobalpostsdisplay == 'content' ) {
    			echo substr( strip_tags( $post['post_content'] ), 0, $recentglobalpostscontentcharacters );
    			echo ' (<a href="' . $post['post_permalink'] . '">' . __('More') . '</a>)';
    		}
    		echo '</li>';
    	}
    }

    And what that should do is simply test that the post is from a Supporter blog, at which point it will display the post, otherwise it wouldn't.

    You can wrap just about anything within the is_supporter() function to achieve a similar effect with virtually any plugin.

    Cheers,
    David

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.