1

I am using this code to reorder the positions of the menu items for BuddyPress profile. I am using the xprofile (not sure if that makes a difference). Here is the code that I am trying to use:

<?php
/*
Plugin name: BP custom
Plugin URI: http://pittbullweb.com
Description: Customs for Buddy Press
Version: 0.1
Author URI: http://pittbullweb.com
*/

function bbg_change_profile_tab_order() {
global $bp;

    $bp->bp_nav['profile']['position'] = 10;
    $bp->bp_nav['activity']['position'] = 20;
    $bp->bp_nav['blogs']['position'] = 30;
    $bp->bp_nav['friends']['position'] = 40;
    $bp->bp_nav['messages']['position'] = 50;
    $bp->bp_nav['groups']['position'] = 60;
    $bp->bp_nav['settings']['position'] = 70;
}
add_action('bp_setup_nav', 'bbg_change_profile_tab_order', 999 );
?>

I am going by the instructions given here to be able to do this. However when I go to activate the plugin i get a fatal error:

Fatal error: Cannot redeclare bbg_change_profile_tab_order() (previously declared in /var/www/vhosts/giftcardswapping.com/demo/wp-content/plugins/bp-custom.php:11) in /var/www/vhosts/giftcardswapping.com/demo/wp-content/plugins/bp-custom.php on line 20

I have also tried renaming the function as well and still receive the same fatal error.

I do not understand how it is redeclared anywhere. I would appreciate any help to figure this out. Thank you.

1

It looks like you have the function both in bp-custom.php and in your plugin.

You don't need a plugin.

Put your code in plugins/bp-custom.php only.

Or in your-theme/functions.php

  • You have to create the bp-custom.php as a plugin as it is not something that comes with BuddyPress. So it shouldn't be creating a conflict. The code was only placed in that file and nowhere else. – Nicole Nov 7 '12 at 21:31
  • 2
    >You have to create the bp-custom.php as a plugin == FALSE. bp-custom is a FILE, not a plug-in. That is the source of your problem. Read the docs: codex.buddypress.org/extending-buddypress/bp-custom-php – shanebp Nov 8 '12 at 16:22
  • If its not a plugin why does it operate from the wp-content/plugins folder? I guess that is where I am confused. And do you have to activate it as a plugin via Wordpress admin? Or does it just run automatically? – Nicole Nov 8 '12 at 20:32
  • It's not a plugin, so you don't have to activate it. Please read the documentation link I provided. Or just try what I suggested in my initial response. Or not... – shanebp Nov 8 '12 at 22:04
  • I did read it i was just confusing myself. I do that quite often sometimes. Thank you for all your help. This worked perfectly. – Nicole Nov 9 '12 at 2:13
0

An easy approach would be to rename your function, this way you won't be re-declaring an already existing function.

Try changing bbg_change_profile_tab_order to my_bbg_change_profile_tab_order

  • Thanks for your suggestion however I have already tried this and still get the same fatal error. – Nicole Nov 7 '12 at 14:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.