Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP 2.6.1.1 – Object of class BP_Core_BP_Nav_BackCompat could not be converted to string error


  • Strothi
    Participant

    @strothi

    Hey guys,

    I keep getting the following error ever since I have tried to update to 2.6.0 up to the current 2.6.1.1:

    Catchable fatal error: Object of class BP_Core_BP_Nav_BackCompat could not be converted to string in /wp-content/plugins/buddypress/bp-core/classes/class-bp-core-nav.php on line 279

    Buddypress 2.5.3 works perfectly. Any idea what’s causing the issue and how to fix it?

    Kind regards,
    Philip

Viewing 6 replies - 1 through 6 (of 6 total)

  • r-a-y
    Keymaster

    @r-a-y

    @strothi – I’ve split your post into a new topic.

    Regarding your error, I’m guessing it is a problem with the BuddyBoss Reorder Tabs plugin.

    Can you confirm? If not, can you list all your BuddyPress plugins?


    Strothi
    Participant

    @strothi

    @r-a-y good catch. I had tried before without some of my custom functions regarding the tab order, but maybe I didn’t delete the cache or whatever, now it works. Though now I can’t use my function that I used up to now to reorder the tabs.

    This is what is used so far:

    function rt_change_profile_tab_order() {
    global $bp;
    $bp->bp_nav['profile']['position'] = 10;
    $bp->bp_nav['activity']['position'] = 20;
    }
    add_action( 'bp_setup_nav', 'rt_change_profile_tab_order', 999 );

    Can you point me to what I need to change to get the same result?

    Thanks so much in advance!


    danbp
    Participant

    @danbp

    Sorry, no idea, that function is still working despite it throws notice. There is a new sort_nav core function since 2.6, but i ignore how to use it in a custom function like these.

    hi @strothi

    here’s a gist to do what you need to do, the right way 😉

    https://gist.github.com/imath/e964da41a85b9e76b679fb946114219c

    For your specific case, you’ll also need to add an extra line to the bp-custom.php file:
    remove_action( 'bp_setup_nav', 'rt_change_profile_tab_order', 999 );

    So that your theme stops doing it the deprecated way.


    danbp
    Participant

    @danbp

    Merci @imath !

    The old way

    The following syntax to change the tab order is deprecated since 2.6 and will throw an error notice:

    function rt_change_profile_tab_order() {
    global $bp;
    $bp->bp_nav['profile']['position'] = 10;
    $bp->bp_nav['activity']['position'] = 20;
    }
    add_action( 'bp_setup_nav', 'rt_change_profile_tab_order', 999 );

    The new way

    Now the correct syntax to use for modifying – since 2.6 – the tabs position on the buddybar when you’re on a profile.

    This example list all BP related items who appear by default on a profile nav, in order of appearance and include also the forum tab (if you use bbPress for group forums).
    By default, activity tab comes as 1st. The snippet will move it to 4th position.

    To modify a position you simply change the numeric value.
    If you want to move only one item, you remove or comment (add // at begin of the line) the ones you don’t want to move.

    function bpex_primary_nav_tabs_position() {
    	buddypress()->members->nav->edit_nav( array( 'position' => 4,	), 'activity' 		);
    	buddypress()->members->nav->edit_nav( array( 'position' => 5, 	), 'profile' 		); 
    	buddypress()->members->nav->edit_nav( array( 'position' => 7, 	), 'notifications'	); 
    	buddypress()->members->nav->edit_nav( array( 'position' => 9,	), 'messages' 	  	);
    	buddypress()->members->nav->edit_nav( array( 'position' => 2,	), 'friends' 	  	);
    	buddypress()->members->nav->edit_nav( array( 'position' => 6,	), 'groups' 		);
    	buddypress()->members->nav->edit_nav( array( 'position' => 3, 	), 'forums' 		);
    	buddypress()->members->nav->edit_nav( array( 'position' => 1, 	), 'settings' 		);
    }
    add_action( 'bp_setup_nav', 'bpex_primary_nav_tabs_position', 999 );

    That’s it for the buddybar nav menu order on profile.


    Strothi
    Participant

    @strothi

    Hey guys,

    thanks a lot. @danbp your code worked perfectly 🙂 The only thing that’s not reordering properly is for some reason the Media tab, which comes from the rtMedia plugin. It worked with my old code when referencing “media”, but for some reason this doesn’t work with your code anymore, even though technically it should! Any idea?

    As for your notice @imath, actually, the change in the default tab had nothing to do with the theme. I just followed this advice: https://codex.buddypress.org/getting-started/guides/change-members-profile-landing-tab/ and put the code into wp-config.

    It works still fine, but I take it from your comment that this way is going to be depreciated and thus I should replace it with your code. Correct?

    Thanks so much for your help guys, highly appreciated!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar