Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 7 years ago

Last modified 5 years ago

#4787 closed defect (bug) (wontfix)

Defining BP_XPROFILE_SLUG throws page not found

Reported by: rogercoathup's profile rogercoathup Owned by:
Milestone: Priority: normal
Severity: normal Version: 1.7
Component: Core Keywords:
Cc:

Description

Trying to change the default profile tab fails.

e.g. adding:

define( 'BP_XPROFILE_SLUG', 'messages' ); in bp-custom.php

causes a Page Not Found error when trying to access the user profile.

Tested using 1.7, bp-default theme, various slugs.

Change History (7)

#1 @DJPaul
12 years ago

  • Milestone changed from Awaiting Review to 1.7

#2 @DJPaul
12 years ago

  • Milestone changed from 1.7 to Future Release

This works for me as long as you don't set those constants to the name of a Page. Punting, as seems an edge case, and should be tidied up with the switch to rewrite rules.

#3 @rogercoathup
12 years ago

have updated to latest beta release, and still seeing this problem.

Throws page not found if I try to set the default profile tab to any of the other standard BuddyPress components, e.g. messages, friends or groups.

If I try to set to a custom component we've added - define( 'BP_XPROFILE_SLUG', 'dashboard' );

It throws the following error:

Warning: require_once(/home/nnn/public_html/wp-content/plugins/nnn-dashboard/includes/templates/members/single/home.php) [function.require-once]: failed to open stream: No such file or directory in /home/nnn/public_html/wp-includes/template.php on line 407

Fatal error: require_once() [function.require]: Failed opening required '/home/nnn/public_html/wp-content/plugins/nnn-dashboard/includes/templates/members/single/home.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/nnn/public_html/wp-includes/template.php on line 407

Where it has appended /members/single/home.php to the template directory of the custom component

#4 @tw2113
8 years ago

I think this one has potential to be closed as wontfix as BP core denotes the fact that the BP_XPROFILE_SLUG has been deprecated and is only still defined for backcompat purposes.

Any thoughts on that idea @boonebgorges @jjj?

Last edited 8 years ago by tw2113 (previous) (diff)

#5 @boonebgorges
7 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Yes, I don't see a way of fixing this without tearing everything apart, which would incur lots of costs for an edge case. Let's close.

#6 @raruto
5 years ago

I think I have found a partial solution (BP 5.1.2).

bp-custom.php

<?php
configuration-settings/#advanced-configurations
define( 'BP_DEFAULT_COMPONENT', 'custom-name' );
define( 'BP_XPROFILE_SLUG', 'custom-name' );

/src/bp-members/classes/class-bp-members-component.php#L242

<?php
...

  $default_component = BP_DEFAULT_COMPONENT;

  // Default behavior
  if ( 'profile' === $default_component ) {
    $default_component = 'xprofile';
  }
  // Check if BP_DEFAULT_COMPONENT == BP_XPROFILE_SLUG
  else if( defined( 'BP_XPROFILE_SLUG' ) && BP_XPROFILE_SLUG === $default_component ) {
    $default_component = 'xprofile';
  }

...

I got inspired by this patch: https://buddypress.trac.wordpress.org/attachment/ticket/6962/6962.01.patch

Sorry if I haven't created a patch, but I haven't had time to go into svn yet...

Version 4, edited 5 years ago by raruto (previous) (next) (diff)

#7 @raruto
5 years ago

For anyone interested here is an alternative solution (without the need to edit source code):

<?php

add_filter('bp_xprofile_slug', function($slug) { return 'custom-name'; });
add_action( 'bp_setup_globals', 'bp_fix_custom_xprofile_slug', 10 );

function bp_fix_custom_xprofile_slug() {
  $bp = buddypress();

  if ( ! empty( $bp->default_component ) || ! empty( $bp->current_component ) ) {
    return;
  }

  $default_component = 'custom-name';

  if ( bp_is_active( $default_component ) ) {
    $bp->default_component = $default_component;
  }

  if ( ! bp_current_component() && bp_displayed_user_id() ) {
    $bp->current_component = $default_component;
  }
}
Last edited 5 years ago by raruto (previous) (diff)
Note: See TracTickets for help on using tickets.