Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: BuddyPress Group Test
- Plugin URI: https://zombo.com
- Description: Test adding group tab
- Version: 1.0
- Author: Kenny Jackson
- Author URI: https://kkjdroid.github.io
- License: AGPLv3
- */
- add_action('bp_actions', function()
- {
- if(bp_is_group())
- {
- $group_slug = bp_get_current_group_slug();
- bp_core_remove_subnav_item("{$group_slug}_manage", 'group-avatar', 'groups');
- }
- else
- {
- bp_core_remove_subnav_item('profile', 'change-avatar', 'members');
- }
- }, 8);
- add_action('bp_setup_nav', function()
- {
- $bp = buddypress();
- if(bp_is_group())
- {
- $group_slug = bp_get_current_group_slug();
- $args =
- [
- 'name' => 'Change Group Photo',
- 'slug' => 'change-group-photo',
- 'rewrite_id' => 'bp_group_manage_change_group_photo',
- 'parent_slug' => "{$group_slug}_manage",
- 'position' => 81,
- 'user_has_access' => true,
- 'show_in_admin_bar' => true,
- 'no_access_url' => bp_get_group_permalink($group_slug),
- 'screen_function' => 'groups_screen_group_admin'
- ];
- $tab = bp_core_new_subnav_item($args, 'groups');
- }
- else
- {
- $tab = bp_core_new_subnav_item(
- [
- 'name' => 'Change Profile Photo',
- 'slug' => 'change-profile-photo',
- 'parent_slug' => $bp->profile->slug,
- 'position' => 30,
- 'user_has_access' => true,
- 'screen_function' => function()
- {
- bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
- add_action('bp_template_content', function()
- {
- echo '<h1>USER</h1>';
- });
- },
- ]);
- }
- }, 100);
- add_action('bp_screens', function()
- {
- if ( 'change-group-photo' != bp_get_group_current_admin_tab() ) {
- return false;
- }
- bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'groups/single/plugins' ) );
- add_action('bp_after_group_home_content', function()
- {
- echo '<h1>GROUP</h1>';
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment