Tagged: x
-
AuthorPosts
-
October 9, 2016 at 5:50 am #1208694
Is there any way of turning off the buddypress and bbpress icons in the navbar for users who are not logged in?
I tried to turn it off by doing the following:
Dashboard settings – Buddypress – Options – ‘Show the toolbar for logged out users’. I unticked this box, but it still appears when users are logged out.
Thanks.
October 9, 2016 at 5:55 am #1208703Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.
October 10, 2016 at 3:48 am #1209580This reply has been marked as private.October 10, 2016 at 4:04 am #1209606I provided my website in the private reply above.
I mentioned that I had put some code I found on another answer on this forum into my functions.php file. It allowed me to remove the ‘Activate your page’ from the submenu, and add in a ‘log out’ link. However, the log out link is also present when you are logged out (not just when you are logged in). Here is the code I applied. Can we tweak it so the logout submenu does not appear when user is already logged out?
I’ve attached the code to this post.
October 10, 2016 at 4:06 am #1209608Actually, if we can hide the buddy press menu on the nav bar from people who are not logged in, that would be ideal. You can let me know if I should delete code from the above file accordingly.
Thanks!
October 10, 2016 at 4:52 am #1209668Hi there,
Please add this code 🙂
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="" 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>'; 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 { $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="" aria-hidden="true"></i> <span>' . __( 'Profile', '__x__' ) . '</span></a></li>'; } if ( $args->theme_location == 'primary' ) { if ( is_user_logged_in() ) { $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>'; } else { $items .= '<li class="menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-buddypress">' . '<a href="' . wp_login_url() . '" class="x-btn-navbar-buddypress">' . '<span><i class="x-icon-user" data-x-icon="" aria-hidden="true"></i><span class="x-hidden-desktop"> ' . __( 'Log in', '__x__' ) . '</span></span>' . '</a>' . '</li>'; } } } return $items; } add_filter( 'wp_nav_menu_items', 'x_buddypress_navbar_menu', 9997, 2 );
That should do it, cheers!
October 10, 2016 at 6:03 am #1209740Thank you for the speedy reply! I’ll try that now – just before I do, can you clarify if I should add the code on top of the rest of the code I had input before, or do I remove the old code and exchange it for this?
Thanks again!
October 10, 2016 at 7:59 am #1209873Hi,
You need to replace the code in your functions.php
Thanks
October 10, 2016 at 8:36 am #1209920Hi again,
I’ve replaced the code but I can’t see the logout sub-menu when I’m logged in…
I notice that there is a different icon now in place of the buddy press person when you are logged out. If I wanted to change this to a different icon, how would I go about doing that?
And thank you for your help! 🙂
October 10, 2016 at 9:56 pm #1210837Hi There,
Please update the code to this to add the logout submenu when logged in.
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="" 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>'; 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 { $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="" aria-hidden="true"></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-sign-out" data-x-icon=""></i> <span>' . __( 'Log Out', '__x__' ) . '</span></a></li>'; } if ( $args->theme_location == 'primary' ) { if ( is_user_logged_in() ) { $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>'; } else { $items .= '<li class="menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-buddypress">' . '<a href="' . wp_login_url() . '" class="x-btn-navbar-buddypress">' . '<span><i class="x-icon-user" data-x-icon="" aria-hidden="true"></i><span class="x-hidden-desktop"> ' . __( 'Log in', '__x__' ) . '</span></span>' . '</a>' . '</li>'; } } } return $items; } add_filter( 'wp_nav_menu_items', 'x_buddypress_navbar_menu', 9997, 2 );
Regarding the icon, the following part handles it:
$items .= '<li class="menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-buddypress">' . '<a href="' . wp_login_url() . '" class="x-btn-navbar-buddypress">' . '<span><i class="x-icon-user" data-x-icon="" aria-hidden="true"></i><span class="x-hidden-desktop"> ' . __( 'Log in', '__x__' ) . '</span></span>' . '</a>' . '</li>';
From the code, it is the same user icon. Your site is not live yet so I can’t see this issue when logout.
Hope this helps.
October 11, 2016 at 3:41 am #1211118Thank you so much for your help. The X Support team is fantastic!
When you are logged out, you can see a ‘login’ icon, and when you click on it, it brings you to the wordpress login screen. This may not be entirely clear to other people what the function of the ‘login’ icon is as they may not have seen it before (I myself wasn’t sure what the icon represented). Would it be possible to make the ‘Create an account’ and ‘Login’ sub-menus visible when people are logged out, so that when they hover over the icon they know what it represents?
Thanks again!
October 11, 2016 at 8:31 am #1211409Hi There,
Please try updating the code to this:
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="" 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>'; 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 { $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="" aria-hidden="true"></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-sign-out" data-x-icon=""></i> <span>' . __( 'Log Out', '__x__' ) . '</span></a></li>'; } if ( $args->theme_location == 'primary' ) { if ( is_user_logged_in() ) { $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>'; } else { $items .= '<li class="menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-buddypress">' . '<a href="' . wp_login_url() . '" class="x-btn-navbar-buddypress">' . '<span><i class="x-icon-user" data-x-icon="" aria-hidden="true"></i><span class="x-hidden-desktop"> ' . __( 'Log in', '__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 );
Hope this helps.
October 11, 2016 at 2:28 pm #1211950Hi Lely! Thank you for this. And I’m now able to see the ‘Log In’, and ‘Create an Account’ feature which I was hoping to see. However, it’s back to showing ‘Activity’, ‘Groups’, ‘Members’ and ‘Activate Your Account’ which I don’t want people who are logged out to have access to. Can these be hidden for logged out users?
Broken down, this is what I would like to be shown:
For logged out users:
– Create an Account
– Log InFor logged in users:
– Activity
– Groups
– Members
– Profile
– LogoutIt’s so close to being perfect! Thank you so much for your help.
October 11, 2016 at 11:09 pm #1212454Hi There,
Thank you for the clarification. Please update to this:
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' ) ) { if ( is_user_logged_in() ) { $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' ) ) { if ( is_user_logged_in() ) { $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>'; } if ( is_user_logged_in() ) { $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>'; } 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 { $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="" aria-hidden="true"></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-sign-out" data-x-icon=""></i> <span>' . __( 'Log Out', '__x__' ) . '</span></a></li>'; } if ( $args->theme_location == 'primary' ) { if ( is_user_logged_in() ) { $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>'; } else { $items .= '<li class="menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-buddypress">' . '<a href="' . wp_login_url() . '" class="x-btn-navbar-buddypress">' . '<span><i class="x-icon-user" data-x-icon="" aria-hidden="true"></i><span class="x-hidden-desktop"> ' . __( 'Log in', '__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 );
Hope this helps.
October 16, 2016 at 11:52 am #1218308This worked perfect – exactly how I want it to appear! Thank you so much! 🙂
-
AuthorPosts