Skip to content

Instantly share code, notes, and snippets.

@MatRouault
Last active February 3, 2020 20:18
Show Gist options
  • Save MatRouault/10053392d1eab1421299 to your computer and use it in GitHub Desktop.
Save MatRouault/10053392d1eab1421299 to your computer and use it in GitHub Desktop.
Add Link to BP Menu (User or Group)
<?php
// Do not include the opening php tag if it is already included in your file.
//* http://buddydev.com/buddypress/add-extra-links-to-buddypress-user-profile-menu-buddypress-group-menu/
add_action( 'after_setup_theme', 'buddydev_register_menus' );
function buddydev_register_menus() {
register_nav_menu( 'bp-profile-extra-links', __( 'Extra profile links' ) );
register_nav_menu( 'bp-group-extra-links', __( 'Extra Group links' ) );
}
add_action( 'bp_member_options_nav', 'buddydev_add_profile_extra_links' );
function buddydev_add_profile_extra_links() {
if ( has_nav_menu( 'bp-profile-extra-links' ) ) {
wp_nav_menu( array( 'container' => false, 'theme_location' => 'bp-profile-extra-links', 'items_wrap' => '%3$s' ) );
}
}
add_action( 'bp_group_options_nav', 'buddydev_add_group_extra_links' );
function buddydev_add_group_extra_links() {
if ( has_nav_menu( 'bp-group-extra-links' ) ) {
wp_nav_menu( array( 'container' => false, 'theme_location' => 'bp-group-extra-links', 'items_wrap' => '%3$s' ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment