Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #394599

    twang
    Participant

    Hi,

    Currently, from the buddypress menu in X, when you roll over the user icon you can see there is a login option. Once logged in, there is no option to log out. Please let me know how add a logout command to this menu drop down.

    Thanks,

    #394670

    Lely
    Moderator

    Hello There,

    Thanks for writing in! Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with adding features to a third party plugin. Although, I can give you the template filename:your-wordpress-folder\wp-content\themes\x\framework\functions\global\plugins\buddypress.php.
    This link might help:https://codex.wordpress.org/Function_Reference/wp_logout_url

    Thank you for your understanding.

    #395189

    twang
    Participant

    Hi,

    Thanks for the quick reply. In searching through the form I noticed that X support has posted a wonderful customization for bbpress that does exactly what I’m trying to do on buddypress. The support post is https://community.theme.co/forums/topic/bbpress-logout/ and I’ve included your code below for the child theme functions.php

    Can I trouble you to help make the modifications to do the same for buddypress? I do not know how to code in php and this would be of tremendous help to me. Many thanks in advance.

    functions.php.
    // Add Logout Link in the menu navigation
    // =============================================================================
    if ( ! function_exists( ‘x_bbpress_navbar_menu’ ) ) :
    function x_bbpress_navbar_menu( $items, $args ) {

    if ( X_BBPRESS_IS_ACTIVE && x_get_option( ‘x_bbpress_header_menu_enable’, ” ) == ‘1’ ) {

    $submenu_items = ”;
    $submenu_items .= ‘<li class=”menu-item menu-item-bbpress-navigation”><i class=”x-icon x-icon-search”></i> <span>’ . __( ‘Forums Search’, ‘__x__’ ) . ‘</span>‘;

    if ( is_user_logged_in() ) {
    $submenu_items .= ‘<li class=”menu-item menu-item-bbpress-navigation”><i class=”x-icon x-icon-star”></i> <span>’ . __( ‘Favorites’, ‘__x__’ ) . ‘</span>‘;
    $submenu_items .= ‘<li class=”menu-item menu-item-bbpress-navigation”><i class=”x-icon x-icon-bookmark”></i> <span>’ . __( ‘Subscriptions’, ‘__x__’ ) . ‘</span>‘;
    }

    if ( ! X_BUDDYPRESS_IS_ACTIVE || X_BUDDYPRESS_IS_ACTIVE && x_get_option( ‘x_buddypress_header_menu_enable’, ” ) == ” ) {
    if ( ! is_user_logged_in() ) {
    $submenu_items .= ‘<li class=”menu-item menu-item-bbpress-navigation”><i class=”x-icon x-icon-sign-in”></i> <span>’ . __( ‘Log in’, ‘__x__’ ) . ‘</span>‘;
    } else {
    $submenu_items .= ‘<li class=”menu-item menu-item-bbpress-navigation”><i class=”x-icon x-icon-cog”></i> <span>’ . __( ‘Profile’, ‘__x__’ ) . ‘</span>‘;
    }
    }

    if ( is_user_logged_in() ) {
    $submenu_items .= ‘<li class=”menu-item menu-item-bbpress-navigation”><i class=”x-icon x-icon-sign-out”></i> <span>’ . __( ‘Log Out’, ‘__x__’ ) . ‘</span>‘;
    }

    if ( $args->theme_location == ‘primary’ ) {
    $items .= ‘<li class=”menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-bbpress”>’
    . ‘
    . ‘<span><i class=”x-icon x-icon-comment”></i><span class=”x-hidden-desktop”> ‘ . __( ‘Forums’, ‘__x__’ ) . ‘</span></span>’
    . ‘

    . ‘<ul class=”sub-menu”>’
    . $submenu_items
    . ‘‘
    . ‘‘;
    }
    }

    return $items;

    }
    add_filter( ‘wp_nav_menu_items’, ‘x_bbpress_navbar_menu’, 9997, 2 );
    endif;
    // =============================================================================

    #395430

    Rue Nel
    Moderator

    Hello There,

    Thanks for updating the thread!

    To add a logout link in your buddyPress menu, please insert the following code in your child theme’s functions.php file

    //
    // Outputs a navigation item with quick links to BuddyPress-specific components
    // such as the activity feed, current member profile, LOGOUT link, et cetera.
    // =============================================================================
     
    if ( ! function_exists( 'x_buddypress_navbar_menu' ) ) :
      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 ( 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=""></i> <span>' . x_get_option( 'x_buddypress_activity_title', __( 'Activity', '__x__' ) ) . '</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=""></i> <span>' . x_get_option( 'x_buddypress_groups_title', __( 'Groups', '__x__' ) ) . '</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=""></i> <span>' . x_get_option( 'x_buddypress_blogs_title', __( 'Blogs', '__x__' ) ) . '</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=""></i> <span>' . x_get_option( 'x_buddypress_members_title', __( 'Members', '__x__' ) ) . '</span></a></li>';
     
          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=""></i> <span>' . x_get_option( 'x_buddypress_register_title', __( 'Create an Account', '__x__' ) ) . '</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=""></i> <span>' . x_get_option( 'x_buddypress_activate_title', __( 'Activate Your Account', '__x__' ) ) . '</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=""></i> <span>' . __( 'Log in', '__x__' ) . '</span></a></li>';
          } else {
            $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_loggedin_user_domain() . '" class="cf"><i class="x-icon-cog" data-x-icon=""></i> <span>' . __( 'Profile', '__x__' ) . '</span></a></li>';
            $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . wp_logout_url() . '" class="cf"><i class="x-icon x-icon-sign-out" data-x-icon=""></i> <span>' . __( 'Log Out', '__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=""></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 );
    endif;

    Please copy the raw code here to preserve the data-x-icon unicode html entity: http://pastebin.com/e8JzK0nn

    Let us know if this has been helpful to you.

    #395560

    twang
    Participant

    Hi, thank you so much for this. It worked perfectly.

    #395644

    Christopher
    Moderator

    You’re welcome.