Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom profile tabs and bubbles in profile


  • Patrick
    Participant

    @zaanmedia

    Hallo everyone,

    I have searched a lot true multiple forums and also here on buddypress. I’m trying to create my first plugin that ads a tab to the profile page with a bubble post count of user x account.

    I found some code that archieve to create the bubble but can’t get the count to work! I need to say im not a programmer so please forgive me for that and hope to learn something why it is not working.

    See the following code:

    function profile_tab_advertenties() {
        global $bp;
    	$count  =  count_user_posts( bp_displayed_user_id() , "post_type"  );
    	$class  = ( 0 === $count ) ? 'no-count' : 'count';
     
        bp_core_new_nav_item( array( 
    		'name' => sprintf( __( 'Advertenties <span class="%s">%s</span>', 'lang-domain' ), esc_attr( $class ), number_format_i18n( $count ) ), 
    		'slug' => 'advertenties', 
            	'screen_function' => 'advertenties_screen', 
            	'position' => 20,
    	    	'parent_url'      => bp_displayed_user_domain()  . '/advertenties/',
    	    	'parent_slug'     => $bp->profile->slug,
    	    	'default_subnav_slug' => 'advertenties'
          ) );
    }
    add_action( 'bp_setup_nav', 'profile_tab_advertenties' );

    I used the following code from @shanepb :

    $count  = // code that retrieves the count
    $class  = ( 0 === $count ) ? 'no-count' : 'count';
    
    bp_core_new_nav_item( array(
        'name'  =>  sprintf( __( 'Animals <span class="%s">%s</span>', 'lang-domain' ), esc_attr( $class ), number_format_i18n( $count ) ),
        // etc

    And added some code behind the $count = // code that retrieves the count.

    Are there any suggestions how i can make this to work!?

    If i do the following code inside a loop it’s working perfect and output the post count of the user.

    <?php echo 'Number of posts published by user: ' . count_user_posts( bp_displayed_user_id() , "post_type" ); ?>

    Thanks,
    Patrick

  • You must be logged in to reply to this topic.
Skip to toolbar