Skip to:
Content
Pages
Categories
Search
Top
Bottom

bp_get_total_site_member_count() not working?


  • Sixtel
    Participant

    @sixtel

    Does anyone know if there is anything special I need to do to get this function to work? It returns 0 to me even though I have members.

    I am using the code in this context…

    //return total buddypress members
    function show_number_of_members( $atts ){
    	$count_members = bp_get_total_site_member_count();
    	return $count_members;
    }
    
    //registers all shortcodes
    function register_shortcodes() {
    	add_shortcode(‘member_count’, ‘show_number_of_members’);
    	add_shortcode( 'postcount', 'post_count_function' );
    }
    
    add_action(init, register_shortcodes);
    
Viewing 4 replies - 1 through 4 (of 4 total)

  • shanebp
    Moderator

    @shanebp

    Try fixing the code first.
    Should be:

    function register_shortcodes() {
    	add_shortcode('member_count', 'show_number_of_members'); // fixed
    	add_shortcode( 'postcount', 'post_count_function' );
    }
    
    add_action('init', 'register_shortcodes');  // fixed

    Sixtel
    Participant

    @sixtel

    Thanks but that doesn’t seem to be the problem. My other shortcode was properly registering and working. I’m not really sure why the ‘ looked funny my original code, it must have came in that way when i pasted it in, but directly pasting in your code did not change anything.


    Sixtel
    Participant

    @sixtel

    Is it confirmed that this function is still working and not deprecated or something?


    shanebp
    Moderator

    @shanebp

    This works for me when pasted in either theme/functions.php or bp-custom.php
    And using the short code on a post or page.

    function sbp_show_number_of_members( $atts ){
    	$count_members = bp_get_total_site_member_count();
    	return $count_members;
    }
    
    function sbp_register_shortcodes() {
    	add_shortcode('member-count', 'sbp_show_number_of_members'); 
    
    }
    add_action('init', 'sbp_register_shortcodes');  
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar