群组的管理 UI 界面

群组的管理 UI 界面

Codex Home → BuddyPress Plugin Development → Admin UI for Groups
Admin UI for Groups

In BuddyPress 1.7, the Groups Component comes with a great Admin UI that allows Community Administrator to easily manage the created groups (members, settings…) directly from the WordPress backend.
Edit Group Admin Screen
As plugin authors, I think we should enjoy this new area and let the Community Administrator manage the settings of the group extension we might use in our custom component. To do so, I think the best way is to enrich the class we use to extend the BP Group Extension API.
Let』s consider this class as our plugin』s group component, just to refresh our memory about the BP Group Extension API  class and its functions:
class Bp_Plugin_Group extends BP_Group_Extension {
function __construct() {}
function create_screen() {}
function create_screen_save() {}
function edit_screen() {}
function edit_screen_save() {}
function admin_screen() {}
function admin_screen_save() {}
function display() {}
function widget_display() {}
function enable_nav_item() {}
}
bp_register_group_extension( 'Bp_Plugin_Group' );

Adding a meta box for our component in the 「Edit Group」 Admin screen.
When creating your component utilizing the BP Group Extension API you can include the functions below to add a meta box to the Group Admin Page. You can create anything from displaying group content or allowing an admin to update the group meta. The  admin_screen_save() function has an example of getting form parameters out of the $_POST global and saving it into the group meta.
function admin_screen( $group_id ) {
?>

The HTML for my admin panel.

name ) ?>

You could display a small snippet of information from your group extension here. It will show on the group
home screen.

<?php
}
}

主题兼容性和模板文件

主题兼容性和模板文件

Codex Home → BuddyPress Theme Development → Theme Compatibility → Theme Compatibility & Template Files
Theme Compatibility & Template Files

An explanation of Theme compatibility and its template files
BuddyPress 1.7 heralded a new era in BP development with a vastly improved approach to templating, its aim being to far more closely mirror the WordPress core templating loading approach.
BuddyPress theme compatibility is based on the great work done by John James Jacoby with the standalone bbPress plugin and ported over to BuddyPress.
What this enhancement means in real terms is that now BuddyPress has the ability to provide its core template files injected into standard WordPress templates in a seamless manner. In other words, users may now choose any WordPress theme for their site and then simply activate the BuddyPress plugin. BuddyPress will automatically check to see if the default BP theme is activated; if not, it will fall back to using the new template files for theme compatibility and select a template file from the parent in the same manner WP does in a template hierarchical fashion
E.G., if your theme has a page.php file, BP will use that file to generate the BuddyPress content
To try and ensure that BP content fits in with a chosen theme as much as is possible, only a very basic set of styles are provided.
When working in theme compatibility mode, BP will look for a series of templates in a specific order much in the same manner WordPress does with it』s main templates ( to better understand template hierarchy read the WP codex page: https://codex.wordpress.org/Template_Hierarchy )
The order of precedence for the file BP will use is:

『plugin-buddypress.php』
『buddypress.php』
『community.php』
『generic.php』
『page.php』
『single.php』
『singular.php』
『index.php』

What this means is BP will look for each named file in the order shown in the stylesheet_directory first (a child theme folder) then in the template_directory (parent theme folder)
As soon as it finds one then that file is used and BP generates its content via this file using the files structure(markup) & get_*( ) calls ( technically BP bypasses the content loop replacing it with the BP content ).
How is this useful?
Use a custom template file for all BP content
This ability to describe what file to use means the user/author may ensure a unique file for BP is used while not having to modify the standard WordPress file e.g. page.php
So if we want to remove the sidebar for BP pages but not for all WP 『pages』 or call a specific BP sidebar get_sidebar(『buddypress』), we could take a copy of page.php and rename it to 『community.php.』 (or 『buddypress.php』) and have BP use this file for all it』s requirements, as can be seen from the order above the first two files will not be found but the third will be and therefore used.
Overloading Template Compatibility theme files
Template compatibility also runs a check to see if two directories or folders exist in a theme:

『buddypress』
『community』

If either of these two folders exist in your theme and they contain BP template files then those files will be used in preference to the bp plugins versions.
Therefore, you can modify any bp theme compatibility template by copying it over from:
/bp-templates/bp-legacy/buddypress/
To:
/my-theme/community/ or /my-theme/buddypress/
N.B. Inside the subfolder 『community』 you must preserve the path structure/folders that exist in the BP original /buddypress/ folder so /activity/ must be created to hold index.php or any of the other activity templates.
Additionally to keep things neat & tidy you can keep your custom parent template file 『community.php』 in these folders as well rather than your theme root.
You may override the css by adding a folder /css/* to your theme root if you then, either, copy buddypress.css from /bp-legacy/ or create a new file named buddypress.css this file will be used instead of the buddypress version.
* As of BP 1.8 the paths for assets i.e styles and JS has been modified to look to your 『buddypress』 or 『community』 folders first, this means you will be able to locate your /css/ folder inside your buddypress one.
Child Themes
As mentioned earlier, BP will search the stylesheet and template paths for BP files/folders. This means that the principle of creating child themes still holds true and is to be a strongly recommended procedure to follow as always.
As a brief example, if you』re creating a theme using TwentyTwelve as a base, instead of dropping custom files into the parent theme you would create 2012-child with a stylesheet style.css that has a header line:
Template: TwentyTwelve
In your child theme you would then have all your custom BP templates this way updating WP will not overwrite any changes you have made.
For information on creating child themes see: https://codex.wordpress.org/Child_Themes
This has been a basic guide to familiarise you with the new template files and how you can make them work for you in your chosen theme and more advanced options exist.
As of BP 1.8 we introduce an enhanced template hierarchy, this new addition allows the developer to specify unique templates for BP screens such as 『Groups』, 『User』 now we can create templates that take a suffix such as a user id, or an 『Action』 or 『Component』; these templates then cut in and provide a custom view in the same manner the template hierarchy does presently in 1.7. You can read a more detailed breakdown and explanation of this new template hierarchy on this page: Enhanced template-hierarchy in BP 1.8

More on BuddyPress 1.7 Theme Compatibility

.htaccess 重定向 FORCE_SSL_ADMIN

.htaccess 重定向 FORCE_SSL_ADMIN

Codex Home → Getting Started → .htaccess redirects for FORCE_SSL_ADMIN
.htaccess redirects for FORCE_SSL_ADMIN

This is a quick reference for anyone that is using FORCE_SSL_ADMIN in their wp-config.php to serve the admin dashboard and user login over https, but would like normal users to browse the frontend over http. BuddyPress implements its own set of redirect to parameters so that normal users are redirected back to the frontend after logging in rather than going straight to the admin dashboard (the default WP behavior). This makes sense as most BP users aren』t going to need to see the dashboard, but when FORCE_SSL_ADMIN is enabled this redirection includes https and causes regular users to browse the frontend over https.
One solution for fixing this is to use .htaccess rules to blanket redirect users who are not browsing the admin dashboard to the http version of your site. Below is some sample .htaccess rewrite rules that should redirect your users to http when they login. Your .htaccess file should be located in your document root, but may vary depending on your configuration.
Make sure that your redirect rules occur before the WordPress section (which is added if you use permalinks). Also, note that the rewrite condition you use to check for https may differ. For example, for some shared hosts you may need to use RewriteCond %{HTTP:X-Forwarded-SSL} on instead.
For more information on .htaccess rules and SSL check out this article.

# This is the additional rewrite section
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule !^wp-(admin/|login.php|includes/|content/)(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

bp_profile_field_data()

bp_profile_field_data()

Codex Home → Developer Resources → Function Examples → bp_profile_field_data()
bp_profile_field_data()

Description
Takes a field name and outputs its corresponding field value. Can be specified by user ID.
Usage
$args = array(
'field' => 'Field Name',
'user_id' => 1
);
bp_profile_field_data( $args );

Parameters

field
(string) Name of profile field to retrieve. The default is false

user_id
(integer) Display field corresponding to a specific user. If no parameter is used, it defaults to bp_displayed_user_id()

Example
To get the current user』s 『Birthday』:
bp_profile_field_data( 'field=Birthday' );
To get User 4』s 『Hire Date』:
bp_profile_field_data( 'field=Hire Date&user_id=4' );
Source File
bp_profile_field_data() is located in bp-xprofile/bp-xprofile-template.php

GSoC 2013

GSoC 2013

Codex Home → GSoC 2013
GSoC 2013

Table of contents

Introduction
Timeline
Ideas

Introduction
Google Summer of Code is a program in which Google sponsors exceptional college students to develop open source code under the guidance of mentoring open source projects. This year, BuddyPress is hoping to be a mentoring organisation.
Know you want to propose a GSoC project around BuddyPress, but aren』t sure what you want to do? Check out our Ideas list below. If you have your own idea for a project, include it in your application and describe it thoroughly. You are not limited to ideas from this list.

Unfortunately, BuddyPress wasn』t chosen to be a mentoring organisation for 2013. However, WordPress did make it in and we can mentor BuddyPress projects under their umbrella, so if you were interested, you should check out https://codex.wordpress.org/GSoC2013 and apply through WordPress.

Timeline

March 18, 19:00 UTC: Mentoring organizations can begin submitting applications to Google.
March 29, 19:00 UTC: Mentoring organization application deadline.
April 1 – 5: Google program administrators review organization applications.
April 8 19:00 UTC: List of accepted mentoring organizations published on the Google Summer of Code 2013 site.
April 9 – 21: Would-be student participants discuss application ideas with mentoring organizations.
April 22, 19:00 UTC: Student application period opens.
May 3, 19:00 UTC: Student application deadline.

Ideas
Project: Extract Notifications into BP-Notifications Component

Brief explanation: Every part of BuddyPress has some kind of interaction with notifications. Since notifications were first introduced, they』ve always treated like second-class citizens. It』s time to elevate this functionality to the major component level it should be in.
Expected results: Make the notifications functionality into a new Notifications Component which can be activated and deactivated at will, then refactor each existing BuddyPress component to work with this new approach.
Knowledge Prerequisite: PHP, WordPress
Questions? Find this person on IRC: jjj

Project: Privacy Component

Brief explanation: Comprehensive privacy controls has been one of the most popular feature requests since the first release of BuddyPress, and while we made some small improvements in BuddyPress 1.6, there』s lots more to do. Provide users with fine, granular control over who has access to which pieces of their BuddyPress-generated personal data.
Expected results: Privacy controls for the users. API for developers to use with other plugins.
Knowledge Prerequisite: PHP, WordPress
Questions? Find any of these people on IRC: boonebgorges, jjj, paulgibbs, r-a-y

Project: Media Albums

Brief explanation: BuddyPress doesn』t have a canonical solution for handling or displaying user-generated content from their other social networks; for example, videos from YouTube and Vimeo, pictures from Flickr, music from soundcloud, and much more. Build a media album that allows users to upload images, but also pull in and display their external content.
Expected results: A media album page added to the user profiles which shows that user』s uploaded images and linked external content.
Knowledge Prerequisite: PHP, Backbone.js, WordPress
Questions? Find this person on IRC: paulgibbs

Project: Unified Activity Stream

Brief explanation: BuddyPress has distinct channels for communication: direct messages, user updates, forums, and blog post comments. This creates a fragmented experience where you』re forced to interact in a variety of different places depending on the type of content. Create a centralised place for all discussion that also routes updates back to the source. e.g. replying to a forum topic creates a reply; replying to a blog post creates a comment.
Expected results: Updated activity templates that unify discussion and act as a central point for interaction on the site.
Knowledge Prerequisite: PHP, Javascript, WordPress
Questions? Find this person on IRC: karmatosed, paulgibbs

Project: Import/Export BuddyPress Data

Brief explanation: To create a backup or migrate a BuddyPress site from one host to another, you currently require technical knowledge as this has to be done at the database/filesystem level. This is not user friendly and contributes to a perception that BuddyPress data somehow has a proprietary lock-in (anything but!). Create an importer/exporter for WordPress that migrates BuddyPress data.
Expected results: WordPress importer/exporter for BuddyPress data.
Knowledge Prerequisite: PHP, XML, WordPress
Questions? Find any of these people on IRC: boonebgorges, jjj, paulgibbs, r-a-y

升级为 BP 1.7 捆绑自定义模板的旧插件

升级为 BP 1.7 捆绑自定义模板的旧插件

Codex Home → BuddyPress Plugin Development → Upgrading older plugins that bundle custom templates for BP 1.7
Upgrading older plugins that bundle custom templates for BP 1.7

This article examines what you can do as a plugin developer to maintain backwards-compatibility template support, while utilizing the newer template-loading approach as featured in BuddyPress 1.7.
We will walk through a real-life case study involving the BP Follow plugin and what was done to update the plugin for BuddyPress 1.7.
Intro
If you created a BuddyPress plugin that bundles custom template files, chances are you might have followed the bp_example_load_template_filter() function approach as recommended by the BP Skeleton Component:
https://github.com/r-a-y/buddypress-skeleton-component/blob/master/includes/bp-example-functions.php#L10
If you didn』t follow this approach, you are lucky! You get to stop reading the rest of this article!
For the rest of you, this approach was fine for versions of BuddyPress previous to 1.7 as BP was only specific to the bp-default theme.
However, if we don』t alter the bp_example_load_template_filter() function, what it actually does is bypass the universal theme compatibility code, which is the main feature in BuddyPress 1.7.
Obviously, we do not want to do that!
Words can only explain so much, so here are some screenshots of the BP Follow plugin before we dive into the tutorial:
Screenshot of the BP Follow plugin running on BP 1.7 before updating the code on the TwentyTen theme:

Screenshot of the BP Follow plugin running on BP 1.7 after updating the code on the TwentyTen theme:

What we』re going to do is make the BP Follow plugin look like the second screenshot so it will be ready for BuddyPress 1.7.
Let』s get started!
(1) Include some 1.7 template-compatibility code with your plugin
BuddyPress 1.7 comes with some awesome new template-loading functions like bp_get_template_part().
However, not everyone will be upgrading to BuddyPress 1.7 immediately, so we need to include some 1.7-compatible code with our plugin to ensure that this new code will work on older BP installs.
A version of this code can be found here:
https://gist.github.com/r-a-y/5119066
Make sure to add it to your plugin』s includes section like so:
if ( ! class_exists( 'BP_Theme_Compat' ) ) {
require( 'THE FILE FROM THE LINK ABOVE AND WHATEVER YOU NAMED IT TO' );
}

For reference, BP Follow does this here:
https://github.com/r-a-y/buddypress-followers/blob/1.2.x/bp-follow-core.php#L54
We will utilize some of these functions a little bit later, but let』s get back to that first screenshot from the Intro section.
(2) A closer look at the 『bp_located_template』 filter
So what is happening in the first screenshot?
If we analyze the bp_follow_load_template_filter() function, we can see that it is similar to the BP Skeleton Component as referenced in the Intro.
What』s happening is BP Follow will always serve its own template:
https://github.com/r-a-y/buddypress-followers/blob/1.1.x/_inc/templates/members/single/following.php
Which is a full page template (using get_header() and get_footer()) and not a template part.
The bp_follow_load_template_filter() function runs on the 'bp_located_template' filter, so let』s examine that for a second:
https://buddypress.trac.wordpress.org/browser/tags/1.7-rc1/bp-core/bp-core-catchuri.php#L378
Since our function always returns a template location, we will bypass the universal theme compatibility code that runs on lines 397-411 and our full page template will be loaded.
We don』t want to do this.
So the first thing we do is alter the function to this:
function bp_follow_load_template_filter( $found_template, $templates ) {
global $bp;

// Only filter the template location when we're on the follow component pages.
if ( ! bp_is_current_component( $bp->follow->followers->slug ) && !bp_is_current_component( $bp->follow->following->slug ) )
return $found_template;

// $found_template is not empty when the older template files are found in the
// parent and child theme
//
// When the older template files are not found, we use our new template method,
// which will act more like a template part.
if ( empty( $found_template ) ) {

// we will add some code here to add our new templates in the next step
}

return apply_filters( 'bp_follow_load_template_filter', $found_template );
}
add_filter( 'bp_located_template', 'bp_follow_load_template_filter', 10, 2 );

What we』re doing here is checking if $found_template is empty.
The passed $found_template variable already tries to find if our full templates:

/members/single/following.php
/members/single/followers.php

exist in the parent or child themes because locate_template() is used.
This is great for themes that might have overriden the old templates that came with BP Follow and handles our backwards-compatibility requirement.
If $found_template is empty, we can start to add some code to add our new template parts!
(3) Get acquainted with the BP Template Stack
The BP Template Stack is a new approach in BP 1.7 to locate templates residing in different directories.
BP handles template stack registration here:
https://buddypress.trac.wordpress.org/browser/tags/1.7-rc1/bp-loader.php#L536
Let』s look at the following lines specifically:
bp_register_template_stack( 'get_stylesheet_directory', 10 );
bp_register_template_stack( 'get_template_directory', 12 );

bp_register_template_stack() is a function that allows us to register a template directory where BP will attempt to find templates in.
The first parameter is a function callback returning a directory that houses templates; the second parameter tells BuddyPress when to look at this directory.
If we look at the above example, what this means is BuddyPress will look in the stylesheet directory (or child theme』s directory) for templates first since it has a priority of 10. Next, BuddyPress will look for templates in the template directory (or parent theme』s directory) if it could not find it in the child theme since it has a priority of 12.
We can also register our own directory to the stack; this is especially beneficial for 3rd-party components and is exactly what we』re doing in BP Follow:
function bp_follow_load_template_filter( $found_template, $templates ) {
global $bp;

// Only filter the template location when we're on the follow component pages.
if ( ! bp_is_current_component( $bp->follow->followers->slug ) && !bp_is_current_component( $bp->follow->following->slug ) )
return $found_template;

// $found_template is not empty when the older template files are found in the
// parent and child theme
//
// When the older template files are not found, we use our new template method,
// which will act more like a template part.
if ( empty( $found_template ) ) {

// register our theme compat directory
//
// this tells BP to look for templates in our plugin directory last
// when the template isn't found in the parent / child theme
bp_register_template_stack( 'bp_follow_get_template_directory', 14 );

// we're not done yet! read on to the next step!
}

return apply_filters( 'bp_follow_load_template_filter', $found_template );
}

Note that 'bp_follow_get_template_directory' is a real function returning the location where our custom templates are housed:
https://github.com/r-a-y/buddypress-followers/blob/1.2.x/_inc/bp-follow-screens.php#L138
We』re giving it a priority of 14 so it is checked after the stylesheet and template directories.
(4) Setup bp-default compatibility
Now, we have to make sure that we still support the bp-default theme, since a lot of people will still be using that theme.
Don』t forget that bp-default has its own page template for plugins where we can inject our plugin content into:

/members/single/plugins.php – members component
/groups/single/plugins.php – groups component

In the BP Follow plugin, since we add new pages to member profiles, we will alter the bp_follow_load_template_filter() function to look for the 'members/single/plugins.php' template:
function bp_follow_load_template_filter( $found_template, $templates ) {
global $bp;

// Only filter the template location when we're on the follow component pages.
if ( ! bp_is_current_component( $bp->follow->followers->slug ) && !bp_is_current_component( $bp->follow->following->slug ) )
return $found_template;

// $found_template is not empty when the older template files are found in the
// parent and child theme
//
// When the older template files are not found, we use our new template method,
// which will act more like a template part.
if ( empty( $found_template ) ) {

// register our theme compat directory
//
// this tells BP to look for templates in our plugin directory last
// when the template isn't found in the parent / child theme
bp_register_template_stack( 'bp_follow_get_template_directory', 14 );

// plugins.php is the preferred template to use, since all we'd need to do is
// inject our content into BP
//
// note: this is only really relevant for bp-default themes as theme compat
// will kick in on its own when this template isn't found
$found_template = locate_template( 'members/single/plugins.php', false, false );

// we're almost there! let's move on to the next step!
}

return apply_filters( 'bp_follow_load_template_filter', $found_template );
}

So what did we just do?
We are redeclaring the passed $found_template variable to look for 'members/single/plugins.php'. locate_template() will attempt to find this template in the child and parent theme and will return the location of this template if found.
Since we』re thinking of bp-default users, this template will always be found since that template is bundled with bp-default. Therefore, this template will be loaded by BuddyPress.
If we』re using any other WordPress theme, BuddyPress』 theme compatibility will kick in later since this template will not be found.
Lastly, we need to setup our new template parts so they will be loaded by BuddyPress.
(5) Setup the new template parts
We』re going to inject our new template parts using the "bp_template_content" hook, which is located in both the bp-default theme and the theme compatibility templates:

https://buddypress.trac.wordpress.org/browser/tags/1.7-rc1/bp-themes/bp-default/members/single/plugins.php#L57
https://buddypress.trac.wordpress.org/browser/tags/1.7-rc1/bp-templates/bp-legacy/buddypress/members/single/plugins.php#L29

Our updated bp_follow_load_template_filter() function looks like this:
https://github.com/r-a-y/buddypress-followers/blob/1.2.x/_inc/bp-follow-screens.php#L60
function bp_follow_load_template_filter( $found_template, $templates ) {
global $bp;

// Only filter the template location when we're on the follow component pages.
if ( ! bp_is_current_component( $bp->follow->followers->slug ) && !bp_is_current_component( $bp->follow->following->slug ) )
return $found_template;

// $found_template is not empty when the older template files are found in the
// parent and child theme
//
// When the older template files are not found, we use our new template method,
// which will act more like a template part.
if ( empty( $found_template ) ) {

// register our theme compat directory
//
// this tells BP to look for templates in our plugin directory last
// when the template isn't found in the parent / child theme
bp_register_template_stack( 'bp_follow_get_template_directory', 14 );

// plugins.php is the preferred template to use, since all we'd need to do is
// inject our content into BP
//
// note: this is only really relevant for bp-default themes as theme compat
// will kick in on its own when this template isn't found
$found_template = locate_template( 'members/single/plugins.php', false, false );

// add our hook to inject content into BP
//
// note the new template name for our template part
add_action( 'bp_template_content', create_function( '', "
bp_get_template_part( 'members/single/follow' );
" ) );
}

return apply_filters( 'bp_follow_load_template_filter', $found_template );
}

So what is happening here?
// add our hook to inject content into BP
//
// note the new template name for our template part
add_action( 'bp_template_content', create_function( '', "
bp_get_template_part( 'members/single/follow' );
" ) );

We are adding a hook to the "bp_template_content" action to load our new template part with the bp_get_template_part() function that we added from our 1.7 compatibility code in step (1).

If you』re wondering what create_function() is for, it』s just a way to create an anonymous function without having to create a real function. You can still create a real function if you wanted to.
For example, you could do this instead:
add_action( 'bp_template_content', 'my_new_template_part_function' );

And somewhere else, you could have my_new_template_part_function() defined like:
function my_new_template_part_function() {
bp_get_template_part( 'members/single/follow' );
);

And the same result would occur. Anyway, back to our regular, scheduled programming!

The new template part resides at:
/members/single/follow.php
If you recall, the old templates in BP Follow reside here:

members/single/following
members/single/followers

For the new template parts, we cannot use the same location and filename due to backwards-compatibility issues.
Hence, for BP Follow, we simply went with /members/single/follow since the 「Following」 and 「Followers」 screens use the same information.
Notice that /members/single/follow is a template part and that the templates reside in a subfolder called 『buddypress』.
The 'buddypress' subfolder is just another one of those cool BP 1.7 features to help separate custom templates in your theme directory just a little bit better.
For example, if you wanted to override the new template part in your Twenty Twelve theme, you could copy 'buddypress/members/single/follow.php' to your theme:
/wp-content/themes/twentytwelve/buddypress/members/single/follow.php
Make a few changes and they would override the bundled template part from BP Follow. To find out a little more about this feature, read this codex article.
If your own BuddyPress plugin uses more than one template, you will have to introduce a bit more logic.
Check out the changes to BP-Album, a plugin that recently implemented the same approach listed above:
https://github.com/BP-Media/bp-album/pull/4
Pay special attention to lines 404-417:
https://github.com/BP-Album/bp-album/blob/master/includes/bpa.core.php#L372
Summary
The bp_follow_load_template_filter() function is now complete! And our second screenshot from step (1) should now show up.
So to summarize, what did we just do?
We:

Added BP 1.7 theme backpat functions so we can use them in our plugin
Allow themes that are already using the older, full page templates to continue working as-is
Change our plugin to use /members/single/plugins.php as the template so we can inject template parts into BP without changing the surrounding markup
Re-route older template locations to use our new template parts to avoid conflicts.

The beauty of this entire approach is older versions of BuddyPress (tested down to v1.5) will inherit some of 1.7』s template-loading features as well, so we get to be both backwards-and-future-compatible with the way we utilize templates in our BuddyPress plugin.

开发者和设计师信息 BP 1.7

开发者和设计师信息 BP 1.7

Codex Home → Legacy Docs → Archived Section: Getting Started → Developer and Designer Information BP 1.7
Developer and Designer Information BP 1.7

Archived file. Good only for BP 1.7 version

BuddyPress 1.7 Theme Compatibility
* Theme Authors, Make Sure Your Theme Registers BuddyPress Support – @boonebgorges
* Add BuddyPress Styles To a Theme – @modemlooper
* Overview of Theme Compatibility in BP 1.7 (Customization) – @hnla
* Upgrading 「Template Packed」 Themes to BP 1.7 Theme Compatibility – @mercime
* New Members Navigation Menus – @hnla
Plugins for BuddyPress 1.7
* Using theme compatibility in plugins – @imath
* Upgrading Older Plugins That Bundle Custom Templates for BP 1.7 – @r-a-y
BP 1.7 Developers and Contributors

BP 1.7 – 升级 「模板打包」 主题

BP 1.7 – 升级 「模板打包」 主题

Codex Home → Legacy Docs → Archived Section: Theme Development → BP 1.7 – Upgrading 「Template Packed」 Themes
BP 1.7 – Upgrading 「Template Packed」 Themes

Archived file. Good up to BP 1.8.

From BuddyPress 1.2 through 1.6.5, most WordPress themes went through the BP Compatibility process via the BuddyPress Template Pack plugin to align the HTML structure of the BP template files with that of the respective WP theme.
BuddyPress 1.7 is now compatible with nearly all WordPress themes available in the market. To make your BP component pages future-proof, it』s time to take advantage of the theme compatibility BP 1.7 brings to the table. Activated BP components will automagically be inserted into your theme』s default page structure.
Upgrading to BP 1.7 – Changing from BP Template Pack to default BP 1.7 Theme Compatibility

Back up or download a copy of your WP theme folder in server which contains the template-packed files or folders.
Deactivate the BP Template Pack plugin in Plugins > Installed.
Delete the six (6) BP folders transferred to your theme』s folder in server when you went through the BP Compatibility Process: /activity, /blogs, /forums, /groups, /members, and /registration. If you have a header-buddypress.php, sidebar-buddypress.php and/or a footer-buddypress.php files, delete those files as well via s/FTP or control panel.
Upgrade to BuddyPress 1.7.
Check out your site』s BP pages – activity, members, etc. – which should contain the respective BP components activated in Settings > BuddyPress.

Frequently Asked Questions
BP 1.7 Theme Compatibility is not working on my theme.
That could be due to a variety of reasons including the WordPress theme』s customized templating, erroneous coding, missing page titles in pages and so forth, all of which are beyond our control. Please create a topic at the BuddyPress Forums and report the problem.
To facilitate troubleshooting, open up your theme』s page.php file, copy all code, paste into pastebin.com and post the generated URL in your support topic. While troubleshooting is going on, re-upload the theme folder you backed up in #1 above which contains the template-packed files/folders to wp-content/themes/ and activate BP Template Pack plugin.
I want to remove the sidebar and have full-width layout for all BuddyPress pages.
1. Open the full-width template in your theme with a text editor and copy all source code.
2. Create a file named buddypress.php and paste the copied source code into the file and save.
3. Upload buddypress.php to your theme』s folder in server i.e., wp-content/themes/yourtheme/
reference: A Brief overview of BuddyPress Theme Compatibility in 1.7
Note: Customize the layouts of BuddyPress pages within the WordPress Default Themes
Why do my sitewide and group forums still have a sidebar even when I uploaded a full-width layout with buddypress.php file?
That』s because since BP version 1.7, sitewide and group forums are rendered by the bbPress plugin. You』d need to copy the full-width template source code into a new file named bbpress.php

bp_member_user_id()

bp_member_user_id()

Codex Home → Developer Resources → Function Examples → bp_member_user_id()
bp_member_user_id()

Description
Get the id of the user in a members loop.
If placed outside of a Members loop, it will be empty.
Usage
bp_member_user_id();

Parameters
None.
Example
Source File
bp_member_user_id() is located in bp-members/bp-members-template.php.

bp_load_theme_functions()

bp_load_theme_functions()

Codex Home → Developer Resources → Function Examples → bp_load_theme_functions()
bp_load_theme_functions()

function bp_load_theme_functions() {
global $pagenow;

// Do not include on BuddyPress deactivation
if ( bp_is_deactivation() )
return;

// Only include if not installing or if activating via wp-activate.php
if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
bp_locate_template( 'buddypress-functions.php', true );
}
}

If you need to stop BuddyPress from loading the buddypress-functions.php file use the remove action below. This is useful if you are supplying functions with your custom BuddyPress theme that may interfere with the core functions.
remove_action( 'bp_after_setup_theme', 'bp_load_theme_functions', 1 );

Source File
bp_load_theme_functions() is located in bp-core/bp-core-template-loader.php