[buddypress-trac] [BuddyPress Trac] #6085: Possible Bug - Notice of Undefined index: position in bp-core-template.php

buddypress-trac noreply at wordpress.org
Fri Jan 2 21:33:00 UTC 2015


#6085: Possible Bug - Notice of Undefined index: position in bp-core-template.php
-------------------------------+------------------------------
 Reporter:  espellcaste        |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Core               |     Version:  2.1
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |
-------------------------------+------------------------------

Comment (by espellcaste):

 Hi @boonebgorges, thanks a lot. Happy New Year for you too! =)

 Firstly let me confirm that the problem wasn't in this particular function
 ('_bp_nav_menu_sort()'). After another calm and closer look, I found out
 the problem was in another function of mine that was changing the name of
 the subnav item, example below:

 {{{
 function test_submenu_name_item() {
         global $bp;

         $bp->bp_options_nav['forums']['assinaturas']['name'] = 'Tópicos
 Assinados';
 }
 add_action('bp_setup_nav', 'test_submenu_name_item', 201);
 }}}

 This function as it is, causes the underfined index: notice error for the
 non logged in user. My guess this happens because this particular item is
 not viewable for the public, so when it goes count the items, it shows the
 error.

 I say this because to correct the notice, I added a check for the logged
 in user and the notice was gone, code below:

 {{{
 function test_submenu_name_item() {
         global $bp;

         if ( is_user_logged_in() )
         $bp->bp_options_nav['forums']['assinaturas']['name'] = 'Tópicos
 Assinados';
 }
 add_action('bp_setup_nav', 'test_submenu_name_item', 201);
 }}}



 ----

 > have you checked whether this happens when using
 bp_core_remove_subnav_item()?


 Yes, I tried to remove the items with this function and it works great,
 except in the situation where you are removing the first item of a
 "group". Example:

 Profile -> View
 Forums -> Topics
 Settings -> General

 If I remove the the sub item Edit, it works as expected, but if I try to
 remove the first item, View, the profile home page doesn't work anymore,
 the same happens to Topics, General and etc. Follows an example:

 {{{
 function test_6085_submenu_remove_item() {
         // Profile
         bp_core_remove_subnav_item( 'profile', 'public' );

         // Forums
         bp_core_remove_subnav_item( 'forums', 'topics' );

         // Setting
         bp_core_remove_subnav_item( 'setting', 'general' );
 }
 add_action('bp_setup_nav', 'test_6085_submenu_remove_item', 201);
 }}}

 It happens because bp_core_remove_subnav_item(), takes the parent item and
 the current slug, that in this case, it's the same as the parent.

 In this case, the unset worked correctly. It removed the items and didn't
 interfered with the the index count.

 {{{
 function test_6085_submenu_remove_item() {

         // Profile
         unset($bp->bp_options_nav['profile']['public']);
 }
 add_action('bp_setup_nav', 'test_6085_submenu_remove_item', 201);
 }}}

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6085#comment:3>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list