Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to customize the user navigation bar and user profile tabs

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

  • r-a-y
    Keymaster

    @r-a-y

    Do you need user blogs?

    If not, disable the blog tracking component.

    Login to the WP backend, navigate to “BuddyPress > Component setup”. Disable blog tracking.


    newbie999
    Participant

    @newbie999

    I only need 1 blog – the main one. I disabled the blog tracking component and that worked, thank you. It disabled all the ‘Blog’ tabs.

    The only thing I need now is a way for the providers (those who can post to the main blog) a way to create/edit posts. Other than adding a meta widget to the sidebar, is there a better way I can provide authors, contributors, etc. a way to get to the dashboard so they can post/edit blog entries?


    jivany
    Participant

    @jivany

    Open up your functions.php file in your child theme and create a function that spits out the links you want. Wrap your links with code to check if the user has the correct capabilities. Hook that function into “bp_sidebar_me” and those links will only show up when the user is logged in and will be in the sidebar under their simple profile.


    newbie999
    Participant

    @newbie999

    Thank you. After searching the forums for how to check the current user’s role, I added below to function.php and it’s working. Since I’m new to this, I’m very open to suggestions if there’s a better way to write this function.

    function my_alter_bp_sidebar_login(){

    global $bp;

    $user = new WP_User( $bp->loggedin_user->id );

    if ( !empty( $user->roles ) && is_array( $user->roles ) ) {

    foreach ( $user->roles as $role )

    if ($role != ‘subscriber’) {

    echo ‘root_domain . ‘/wp-admin/”>Dashboard<p/>’;

    }

    }

    }

    add_action(‘bp_before_sidebar_me’,’my_alter_bp_sidebar_login’,1);


    jivany
    Participant

    @jivany

    It might be cleaner to use the current_user_can function to test. Check out the Roles info on the WP Codex, specifically the table (it makes it easy to see what roles apply):

    https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table

    To make it a little cleaner you could do the following:

    function my_alter_bp_sidebar_login () {
    if( current_user_can( 'edit_posts' ) ) {
    printf( '<a href="%s" title="Dashboard">Dashboard</a>',(get_bloginfo( 'wpurl' ).'/wp-admin/') );
    }
    }

    This would show the link for any user who can “edit_posts” which is basically anyone other than Subscriber.


    newbie999
    Participant

    @newbie999

    Thank you much for the better, cleaner, shorter code and the link! I’m learning every day!


    newbie999
    Participant

    @newbie999

    Hello again. I posted this question on a new topic, no responses. I’ll try asking the question here since I have received responses on this thread. Thank you. Here goes:

    I added the code below in wp-content/plugins/buddypress/bp-themes/bp-default/members/members-loop.php, to display additional profile fields in the member directory and to display the member’s role (either ‘Subscriber’ or ‘Provider’). In the code below, I specifically checked for the user’s role to determine whether I need to display ‘Subscriber’ or ‘Provider’.

    Questions:

    – is there a way to check for the capability instead – i.e., if the user can ‘edit posts’ then I will display ‘Subscriber’, otherwise I will display ‘Provider’? If so, can you please let me know how to do that as I have not been able to figure it out.

    – is there a way to display a newline so that ‘Subscriber’ or ‘Provider’ will display on the next line, below the member’s title and company name. I tried to echo “n” but it’s not outputting a newline and I have no idea why.

    Thank you for the help.

    <?php

    /***

    * If you want to show specific profile fields here you can,

    * but it’ll add an extra query for each member in the loop

    * (only one regadless of the number of fields you show):

    *

    * bp_member_profile_data( ‘field=the field name’ );

    */

    if( bp_get_member_profile_data ( ‘field=Title’ ) )

    echo bp_member_profile_data( ‘field=Title’ ), ‘ (‘, bp_member_profile_data( ‘field=Company’ ), ‘)’, ‘ – ‘;

    $user = new WP_User( bp_get_member_user_id() );

    if ( $user->roles[0] == ‘subscriber’ )

    echo ‘Subscriber’;

    else

    echo ‘Provider’;

    ?>


    newbie999
    Participant

    @newbie999

    Hello again. I posted this question on a new topic, no responses. I’ll try asking the question here since I have received responses on this thread. Thank you. Here goes:

    I added the code below in wp-content/plugins/buddypress/bp-themes/bp-default/members/members-loop.php, to display additional profile fields in the member directory and to display the member’s role (either ‘Subscriber’ or ‘Provider’). In the code below, I specifically checked for the user’s role to determine whether I need to display ‘Subscriber’ or ‘Provider’.

    Questions:

    – is there a way to check for the capability instead – i.e., if the user can ‘edit posts’ then I will display ‘Subscriber’, otherwise I will display ‘Provider’? If so, can you please let me know how to do that as I have not been able to figure it out.

    – is there a way to display a newline so that ‘Subscriber’ or ‘Provider’ will display on the next line, below the member’s title and company name. I tried to echo “n” but it’s not outputting a newline and I have no idea why.

    Thank you for the help.

    <?php

    /***

    * If you want to show specific profile fields here you can,

    * but it’ll add an extra query for each member in the loop

    * (only one regadless of the number of fields you show):

    *

    * bp_member_profile_data( ‘field=the field name’ );

    */

    if( bp_get_member_profile_data ( ‘field=Title’ ) )

    echo bp_member_profile_data( ‘field=Title’ ), ‘ (‘, bp_member_profile_data( ‘field=Company’ ), ‘)’, ‘ – ‘;

    $user = new WP_User( bp_get_member_user_id() );

    if ( $user->roles[0] == ‘subscriber’ )

    echo ‘Subscriber’;

    else

    echo ‘Provider’;

    ?>


    Nahum
    Participant

    @nahummadrid

    how would you remove items from the menu without disabling the component? Still want to make use of blog tracking but don’t need the blogs menu item. If members are only allowed 1 blog there is really no need for this in the menu.


    techguy
    Participant

    @crashutah

    @nahummadrid
    To remove the blog component from the top menu bar I think you can do:
    remove_action(‘bp_adminbar_menus’, ‘bp_adminbar_blogs_menu’, 6);


    Nahum
    Participant

    @nahummadrid

    @techguy thanks but i did try that and it only removes from adminbar not the member profile nav bar. what i’ve ended up doing that works i guess is to use css.

    #blogs-personal-li {
    display:none;
    }


    makingtrails
    Member

    @makingtrails

    How about renaming the blog name to ‘ Welcome, [USER] ‘

    Is this just a case of replacing the action with a new action ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to customize the user navigation bar and user profile tabs’ is closed to new replies.
Skip to toolbar