Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1013970
    twigglee
    Participant

    Hi there!
    I have posted in BuddyPress forums but nobody replies so I’m hoping someone here can help.
    I would like to delete some of the drop down options the original drop down menu includes for BuddyPress.
    Example:
    For non-logged in people viewing the site, I’d like to just have the “Log-in” and “Register” options there.
    For logged in people, I’d like to add “Log-out” option.
    Any help is appreciated. Thanks! 🙂

    #1014102
    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in!

    To resolve this issue, what you are trying to accomplish requires a template customization, we would like to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    Once you already have your child theme active and ready, please insert this following code in your child theme’s functions.php file.

    function x_buddypress_navbar_menu( $items, $args ) {
    
      if ( X_BUDDYPRESS_IS_ACTIVE && x_get_option( 'x_buddypress_header_menu_enable' ) == '1' ) {
    
        if ( bp_is_active( 'activity' ) ) {
          $logged_out_link = bp_get_activity_directory_permalink();
        } else if ( bp_is_active( 'groups' ) ) {
          $logged_out_link = bp_get_groups_directory_permalink();
        } else {
          $logged_out_link = bp_get_members_directory_permalink();
        }
    
        $top_level_link = ( is_user_logged_in() ) ? bp_loggedin_user_domain() : $logged_out_link;
        $submenu_items  = '';
    
        if ( ! is_user_logged_in() ) {
          if ( bp_get_signup_allowed() ) {
            $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_signup_page() . '" class="cf"><i class="x-icon-pencil" data-x-icon="" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_register_title' ) . '</span></a></li>';
            $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_activation_page() . '" class="cf"><i class="x-icon-key" data-x-icon="" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_activate_title' ) . '</span></a></li>';
          }
          $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . wp_login_url() . '" class="cf"><i class="x-icon-sign-in" data-x-icon="" aria-hidden="true"></i> <span>' . __( 'Log in', '__x__' ) . '</span></a></li>';
        } else {
    
          if ( bp_is_active( 'activity' ) ) {
            $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_activity_directory_permalink() . '" class="cf"><i class="x-icon-thumbs-up" data-x-icon="" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_activity_title' ) . '</span></a></li>';
          }
    
          if ( bp_is_active( 'groups' ) ) {
            $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_groups_directory_permalink() . '" class="cf"><i class="x-icon-sitemap" data-x-icon="" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_groups_title' ) . '</span></a></li>';
          }
    
          if ( is_multisite() && bp_is_active( 'blogs' ) ) {
            $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_blogs_directory_permalink() . '" class="cf"><i class="x-icon-file" data-x-icon="" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_blogs_title' ) . '</span></a></li>';
          }
    
          $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_members_directory_permalink() . '" class="cf"><i class="x-icon-male" data-x-icon="" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_members_title' ) . '</span></a></li>';
    
          $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . wp_logout_url() . '" class="cf"><i class="x-icon-sign-out" data-x-icon="" aria-hidden="true"></i> <span>' . __( 'Logout', '__x__' ) . '</span></a></li>';
        }
    
        if ( $args->theme_location == 'primary' ) {
          $items .= '<li class="menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-buddypress">'
                    . '<a href="' . $top_level_link . '" class="x-btn-navbar-buddypress">'
                      . '<span><i class="x-icon-user" data-x-icon="" aria-hidden="true"></i><span class="x-hidden-desktop"> ' . __( 'Social', '__x__' ) . '</span></span>'
                    . '</a>'
                    . '<ul class="sub-menu">'
                      . $submenu_items
                    . '</ul>'
                  . '</li>';
        }
      }
    
      return $items;
    
    }
    add_filter( 'wp_nav_menu_items', 'x_buddypress_navbar_menu', 9997, 2 );

    Please copy the raw code here (http://pastebin.com/pB4iesbQ) to preserve the unicode html entities or the data-x-icon value.

    Please let us know if this works out for you.

    #1014293
    twigglee
    Participant
    This reply has been marked as private.
    #1014321
    Christopher
    Moderator

    Hi there,

    Please connect to FTP account, navigate to wp-content/themes/x-child and insert the code in functions.php file.
    Regretfully, at this time I am not entirely certain what it is you would like to accomplish based on the information given in your post. If you wouldn’t mind providing us with a little more clarification on what it is you’re wanting to do (a link to a similar example site would be very helpful, or perhaps some screenshots), we’ll be happy to provide you with a response once we have a better understanding of the situation.

    Thanks.

    #1014325
    twigglee
    Participant

    Hi!
    Sorry for not clarifying. I’m still setting up child theme and uncertain to what to put in “Theme URI” part. (Ive never made a child theme before)
    ” Theme URI: http://example.com/twenty-fifteen-child/
    Is it something similar to ” http://theme.co/x/demo/icon/3/ ” ?
    Thanks

    #1014359
    Christopher
    Moderator

    Hi there,

    I’m still unsure what you’re referring to. Are you referring to the comment part at the beginning of style.css file ?

    /*
    
    Theme Name: X &ndash; Child Theme
    Theme URI: http://theme.co/x/
    Author: Themeco
    Author URI: http://theme.co/
    Description: Make all of your modifications to X in this child theme.
    Version: 1.0.0
    Template: x
    
    */

    No need to change anything, it’s comment and has no affect on your site. Please follow this link to setup a child theme https://theme.co/x/member/kb/how-to-setup-child-themes/

    Thanks.

    #1014379
    twigglee
    Participant

    Thanks that was a lot easier. I was trying to manually install it before.

    I think I got it working.

    Last thing is, how can I add to the above code and disable the “activate” drop down option as well?
    Thanks! 🙂

    #1014648
    Rad
    Moderator

    Hi there,

    You can just append the code to your child theme’s functions.php by either File manager’s editor, or by text editor through FTP.

    And from the code provided, you can remove this line to remove “activate” item.

     $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_activation_page() . '" class="cf"><i class="x-icon-key" data-x-icon="" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_activate_title' ) . '</span></a></li>';
    

    Thanks!

    #1014902
    twigglee
    Participant

    Thank you! 🙂

    #1014945
    Rue Nel
    Moderator

    You are most welcome!

  • <script> jQuery(function($){ $("#no-reply-1013970 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>