BuddyDev

Search

visitor counter

  • Participant
    Level: Enlightened
    Posts: 94
    Ankit Raj on #30801

    hi i have installed recent visitors profile plugin and i have added it to my navigation menu but it doesnot show counter for new visitors in menu

  • Keymaster
    (BuddyDev Team)
    Posts: 24611
    Brajesh Singh on #30802

    Please provide screenshot to clarify the context. If you are referring to WordPress nav menu, we do not provide any way to have counter there. If you are referring to BuddyPress profile abs/nav, then we do.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 94
    Ankit Raj on #30817

    https://photos.app.goo.gl/reN7qokcEAjDkZCC7 here in this menu you can see i have added vositors menu

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #30821

    Hello Ankit,

    It seems, It’s a normal WordPress menu “Visitors”. Please let me know if you are adding this menu using WordPress admin menu section yes or no.

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 94
    Ankit Raj on #30822

    Hi Ravi yes i have added it by WordPress menu section as buddypress provides this option and i have added it to menu

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #30834

    Hello Ankit,

    As per replied earlier in #30802. We do not provide any way to have counter there. Sorry, But I can not help you much here

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 94
    Ankit Raj on #30835

    Is there a way for that

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #30836

    Hello Ankit,

    Try using with code. Check the following code adding a login/logout menu.

    
    function add_login_logout_link($items, $args) {
    	$loginoutlink = wp_loginout('index.php', false);
    	$items .= '<li>'. $loginoutlink .'</li>';
    	return $items;
    }
    add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
    

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 94
    Ankit Raj on #30837

    Where do I add the code

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #30844

    Hello Ankit,

    Above code provided just a sample code How to add a nav item using code. Please try the following code in your active theme “functions.php” file. It will add a menu with name “Visitors” and count. Please make sure you have enabled “Show a profile tab?” setting.

    
    /**
     * Add visitors link
     *
     * @param string   $items The HTML list content for the menu items.
     * @param stdClass $args  An object containing wp_nav_menu() arguments.
     *
     * @return string
     */
    function add_visitors_link( $items, $args ) {
    
        if ( ! is_user_logged_in() || ! function_exists( 'buddypress' ) || ! function_exists( 'visitors_get_profile_visit_count' ) ) {
            return $items;
        }
    
        $visitors_count = visitors_get_profile_visit_count( bp_loggedin_user_id() );
    
    	$visitors_tab_url = trailingslashit( bp_loggedin_user_domain() . 'visitors' );
    
    	$items .= sprintf( '<li><a href="%s">%s <span>%s</span></a></li>', esc_url( $visitors_tab_url ), __( 'Visitors', 'buddypress' ), $visitors_count );
    
    	return $items;
    }
    
    add_filter( 'wp_nav_menu_items', 'add_visitors_link', 10, 2 );
    
    

    Regards
    Ravi

The topic ‘visitor counter’ is closed to new replies.

This topic is: not resolved