Add BuddyPress Create Group Button to User Profile Groups Page Navigation
I have seen too many people asking for it. Do you want to add a Create Group sub nav under your BuddyPresss Profile Group page? If yes, here goes the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /** * Add Create Group sub nav to User Profile->Groups screen */ function buddydev_custom_add_create_group_tab_to_profile_nav() { if ( ! bp_is_my_profile() ) { return; } $slug = bp_get_groups_slug(); $access = bp_core_can_edit_settings() && bp_user_can_create_groups(); $groups_link = trailingslashit( bp_core_get_user_domain() . $slug ); bp_core_new_subnav_item( array( 'name' => __( 'Create' ), 'slug' => 'create-group', 'parent_slug' => $slug, 'parent_url' => $groups_link, 'position' => 1010, 'user_has_access' => $access, 'screen_function' => function () { }, 'show_in_admin_bar' => false, 'link' => trailingslashit( bp_get_groups_directory_permalink() . 'create' ), ) ); } add_action( 'bp_groups_setup_nav', 'buddydev_custom_add_create_group_tab_to_profile_nav', 100 ); |
You can put the code in your theme/child theme's functions.php or in wp-content/plugins/bp-custom.php
Here is a screenshot showing it in action:-
It works with both the template packs(Whether you use BP Nouveau or BuddyPress Legacy template pack, it will work).
Enjoy 🙂
Hello Everyone,
It is a little contribution.
For youzer users, if you want to display a pen icon before 'create a group' option, you can use this css code to do it. Add this one in the custom css panel of your theme.
.
Thank you for sharing.