koka-boka
Jun 10th, 2024 (edited)
466
0
Never
This is comment for paste Untitled
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Hello @kkjdroid. I'm not sure I understood you correctly. Still, I made some changes, try it.
  2.  
  3. <?php
  4. /*
  5. Plugin Name: BuddyPress Group Test
  6. Plugin URI: n/a
  7. Description: Test adding group tab
  8. Version: 0.0.1
  9. Author: n/a
  10. Author URI: n/a
  11. License: AGPLv3
  12. */
  13.  
  14. add_action('bp_actions', function() {  
  15.     if (bp_is_group()) {
  16.         $group = groups_get_current_group();
  17.         if ($group) {
  18.             $group_slug = $group->slug;
  19.             bp_core_remove_subnav_item($group_slug . '_manage', 'group-avatar', 'groups');
  20.         }
  21.     } else {
  22.         bp_core_remove_subnav_item('profile', 'change-avatar', 'members');
  23.     }
  24. });
  25.  
  26. add_action('bp_setup_nav', function() {
  27.     $bp = buddypress();
  28.     if (bp_is_group()) {
  29.         $group = groups_get_current_group();
  30.         if ($group) {
  31.             $group_slug = $group->slug;
  32.             $parent_url = trailingslashit(bp_get_group_permalink($group)) . 'admin/';
  33.             bp_core_new_subnav_item([
  34.                 'name' => 'Change Group Photo',
  35.                 'slug' => 'change-group-photo',
  36.                 'parent_url' => $parent_url,
  37.                 'parent_slug' => $group_slug . '_manage',
  38.                 'position' => 30,
  39.                 'screen_function' => function() {
  40.                     bp_core_load_template(apply_filters('bp_core_template_plugin', 'groups/single/plugins'));
  41.                     add_action('bp_template_content', function() {
  42.                         echo '<h1>GROUP</h1>';
  43.                     });
  44.                 },
  45.             ]);
  46.         }
  47.     } else {
  48.         if (is_user_logged_in()) {
  49.             $user = wp_get_current_user();
  50.             $parent_url = trailingslashit($bp->loggedin_user->domain . $bp->profile->slug);
  51.             bp_core_new_subnav_item([
  52.                 'name' => 'Change Profile Photo',
  53.                 'slug' => 'change-profile-photo',
  54.                 'parent_url' => $parent_url,
  55.                 'parent_slug' => $bp->profile->slug,
  56.                 'position' => 30,
  57.                 'screen_function' => function() {
  58.                     bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
  59.                     add_action('bp_template_content', function() {
  60.                         echo '<h1>USER</h1>';
  61.                     });
  62.                 },
  63.             ]);
  64.         }
  65.     }
  66. }, 10);
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment