Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to Keep Blog Tracking but Hide Blogs(0) tab for non-blogging Members


  • Nahum
    Participant

    @nahummadrid

    Most members will not have a blog in most cases. How can I can keep blog tracking but hide the blogs tab in the user nav when Blogs(0)?

Viewing 20 replies - 1 through 20 (of 20 total)

  • Nahum
    Participant

    @nahummadrid

    Anyone have a clue how to show object nav tabs only if they exist for a member for example if blogs(0), links(0) tab then hide!


    Boone Gorges
    Keymaster

    @boonebgorges

    Try putting this in your plugins/bp-custom.php file:

    function remove_blogs_nav_for_zero() {
    global $bp;

    if ( bp_blogs_total_blogs_for_user() == 0 )
    bp_core_remove_nav_item( $bp->blogs->slug );
    }
    add_action( 'bp_setup_nav', 'remove_blogs_nav_for_zero', 11 );


    Nahum
    Participant

    @nahummadrid

    Bang!

    thanks. now lets see if i can apply that to bp links and others

    Thanks @boonebgorges


    Boone Gorges
    Keymaster

    @boonebgorges

    You got it!


    r-a-y
    Keymaster

    @r-a-y

    I can confirm it works ;)


    @mercime
    Keymaster

    @mercime

    Re: blog tracking – I may have overlooked something, but I recall that once you’re a member of BP community in main site or where BP is defined in install, you already have one blog counted in the site. And when a member creates a blog within the install, the member has now two blogs to his/her credit.
    So wouldn’t it be logical to have `if ( bp_blogs_total_blogs_for_user() == 1 )` instead in the function?


    r-a-y
    Keymaster

    @r-a-y

    I don’t think that’s the case.

    You only have a blog if you’re the administrator of a blog.


    Nahum
    Participant

    @nahummadrid

    the main site was assigned to members a while back in an earlier version 1.1 round abouts(i remember because i had asked about it a while back because I was having issues with the limit blogs per user plugin)….it’s been “fixed” since then not to assign the main site as one of your blogs.


    r-a-y
    Keymaster

    @r-a-y

    That’s correct, Nahum.


    imjscn
    Participant

    @imjscn

    I’m using child them which only has a style.css, I don’t have this bp_custom.php file in either bp-default them or child them. Can I create this bp_custom.php in Child them folder? Is it ok if this file contain only the above code?

    bp-custom.php never exists it’s user created, it can contain nothing at all if you wish.


    Boone Gorges
    Keymaster

    @boonebgorges

    And make sure that bp-custom.php goes in your wp-content/plugins directory, NOT in the theme folder.


    imjscn
    Participant

    @imjscn

    I created an empty bp_custom.php in wp-content/plugins folder, added the above code. but nothing happened. no matter I put in == 0, or == 1, or == 2, the blogs tab is still there.
    Maybe because my user profile is at root directory? ( http://mydomain.com/username/ )


    Roger Coathup
    Participant

    @rogercoathup

    @imjscn – you’ve got the file name wrong, you need a hyphen not an underscore bp-custom.php


    imjscn
    Participant

    @imjscn

    ok, I changed to bp-custom.php, this time something happens– the code shows up at my blog header area pushing the header picture down 2 lines, and the blogs tab still in profile page. ( I tried both copy/paste the code or hard typing, get the same result. Also tried to change the files Charactor Encoding from us-ascii to utf-8, neither works). Please help!!!


    Boone Gorges
    Keymaster

    @boonebgorges

    At the beginning of your bp-custom.php file, make sure you have
    `<?php`
    and at the end make sure you have
    `?>`


    imjscn
    Participant

    @imjscn

    OMG, what a super dummy I am !!!
    Thanks! Fully dancing after the magical marks


    imjscn
    Participant

    @imjscn

    @boonebgorges, if I want to do this on the header of profile page—
    if user ID is 1 or 2, display

    ABC

    instead of

    “last update’, “mention this user”….

    if user is anybody else, display item-meta as normal.
    How to do this?


    Roger Coathup
    Participant

    @rogercoathup

    @imjscn – post that as a separate support question


    Nahum
    Participant

    @nahummadrid

    I thought the same would work for groups…but it’s throwing the group count # up above the header when I use alone or in conjunction with the blogs snippet.

    `function remove_groups_nav_for_zero() {
    global $bp;
    if ( bp_groups_total_count_for_user() == 0 )
    bp_core_remove_nav_item( $bp->groups->slug );
    }
    add_action( ‘bp_setup_nav’, ‘remove_groups_nav_for_zero’, 11 );
    `

    Any ideas why this is happening…and not with the blogs one.

Viewing 20 replies - 1 through 20 (of 20 total)
  • The topic ‘How to Keep Blog Tracking but Hide Blogs(0) tab for non-blogging Members’ is closed to new replies.
Skip to toolbar