配置组件 (v1.5)

配置组件 (v1.5)

Codex Home → Legacy Docs → Archived Section: Getting Started → Configuring Components (v1.5)
Configuring Components (v1.5)

Archived file. Good up to BP 1.5 version

After activating BuddyPress 1.5+ and going through the new installation wizard, there will be five new admin panels where you will be able to configure the plugin further

BuddyPress > Components panel
BuddyPress > Pages panel
BuddyPress > Settings panel
BuddyPress > Forums panel
BuddyPress > Extended Profile Fields panel

For single WordPress installations, you』ll find the BuddyPress menu in the regular wp-admin dashboard. For WordPress Multisite installations, you』ll find the BuddyPress menu in the Network Admin dashboard.
BuddyPress > Components
By default, all BuddyPress components are enabled. You can selectively disable any of the components by using the form. Your BuddyPress installation will continue to function. However, the features of the disabled components will no longer be accessible to anyone using the site

Available Components
Each component has a unique purpose, and your community may not need each one.

Extended Profiles
Customize your community with fully editable profile fields that allow your users to describe themselves.
Account Settings
Allow your users to modify their account and notification settings directly from within their profiles.
Friend Connections
Let your users make connections so they can track the activity of others and focus on the people they care about the most.
Private Messaging
Allow your users to talk to each other directly and in private. Not just limited to one-on-one discussions, messages can be sent between any number of members.
Activity Streams
Global, personal, and group activity streams with threaded commenting, direct posting, favoriting and @mentions, all with full RSS feed and email notification support.
User Groups
Groups allow your users to organize themselves into specific public, private or hidden sections with separate activity streams and member listings.
Discussion Forums
Full-powered discussion forums built directly into groups allow for more conventional in-depth conversations. NOTE: This will require an extra (but easy) setup step.
Site Tracking
Make BuddyPress aware of new posts and new comments from your site.
N.B. 「Network mode」 is a feature of WordPress that needs to be manually enabled and configured first. Instructions for enabling this can be found on the WordPress codex WP Codex – Create A Network

Required Components
The following components are required by BuddyPress and cannot be turned off.

BuddyPress Core: It『s what makes [time travel] BuddyPress possible!
Community Members: Everything in a BuddyPress community revolves around its members.

BuddyPress > Pages

BuddyPress components are rendered as WordPress Pages in BuddyPress 1.5. You』ll recall that the above Pages were created and associated to respective BP components in Step 2 of the Installation Wizard.

Directories
Associate a WordPress Page with each BuddyPress component directory.

Activity Streams
Discussion Forums
User Groups
Members

Registration
Associate WordPress Pages with the following BuddyPress Registration pages.

Register
Activate

BuddyPress > Settings

Disable BuddyPress to WordPress profile syncing? (default: No)
Hide admin bar for logged out users? (default: No)
Disable avatar uploads? Gravatars will still work (default: No)
Disable user account deletion? (default: No)
Disable activity stream commenting on blog and forum posts? (default: No)
Restrict group creation to Site Admins? (default: No)

BuddyPress > Forums
Three choices are available: Group Forums only, Sitewide Forums only, or Group and Sitewide Forums. Proceed to the illustrated step-by-step guide to set up both forums.

BuddyPress > Profile Fields
Your users will distinguish themselves through their profile page. You must give them profile fields that allow them to describe themselves in a way that is relevant to the theme of your social network.
Note: Any fields in the first group will appear on the signup page.

BP-Default 默认主题版本

BP-Default 默认主题版本

Codex Home → Legacy Docs → Archived Section: Theme Development → The BuddyPress Default Theme → BP-Default Theme Versions
BP-Default Theme Versions

Archived file. The BP Default theme will no longer be activated in new installations and will be retired in the near future. http://bpdevel.wordpress.com/2013/11/13/the-future-of-the-bp-default-theme/

Past versions of BP-Default BuddyPress Theme.
1.5.6 (svn)
1.5.5 (svn)
1.5.4 (svn)
1.5.3.1 (svn)
1.5.3 (svn)
1.5.2 (svn)
1.5.1 (svn)
1.5 (svn)
1.2.10 (svn)
1.2.9 (svn)
1.2.8 (svn)
1.2.7 (svn)
1.2.6 (svn)
1.2.5.2 (svn)
1.2.5.1 (svn)
1.2.5 (svn)
1.2.4.1 (svn)
1.2.4 (svn)
1.2.3 (svn)
1.2.2 (svn)
1.2.1 (svn)
1.2 (svn)
1.1.3 (svn)
1.1.2 (svn)
1.1.1 (svn)
1.1 (svn)
1.0.3 (svn)
1.0.2 (svn)
1.0.1 (svn)
1.0 (svn)

安装向导

安装向导

Codex Home → Legacy Docs → Archived Section: Getting Started → Installation Wizard
Installation Wizard

Archived file. This information is for BuddyPress installations up to version 1.6.5 only. There is no installation wizard for BuddyPress version 1.7 and above

After installing and activating BuddyPress, you will see an admin message with the link to the new BuddyPress Installation Wizard. Click on the "installation wizard" link.

Step 1: Choose the BuddyPress Components you want in your installation.
IMPORTANT: Do not select the 「Discussion Forums」 component
If you』ve never installed BuddyPress before, do not select the 「Discussion Forums」 component.
Instead if you want to enable sitewide or group forums, download the latest version of bbPress. bbPress will handle group forum integration in BuddyPress going forward -> https://codex.buddypress.org/user/setting-up-a-new-installation/installing-group-and-sitewide-forums/
Click on "Save & Next" button.

Step 2: Associate/Create Pages for your BuddyPress Components.
Click on "Save & Next" button.

Step 3: Choose Pretty Permalinks structure.
Click on "Save & Next" button.

Step 4: Choose theme to use for your BP install.
Recommend using the bp-default theme to test drive all the BP features you activated. Click on "Save & Next" button.

Step 5: Finish and Activate

Proceed to Next Task
Configure BuddyPress Components

升级到 1.6

升级到 1.6

Codex Home → Releases → Version 1.6 → Upgrading to 1.6
Upgrading to 1.6

Note: If you』re using a BuddyPress 1.2 install and you want to upgrade to 1.6, please upgrade to 1.5 first. Then follow this guide.

BuddyPress 1.6 is a brand-new release featuring many improvements and features. Read about these features and improvements here.
How to Upgrade
You can upgrade through the regular WordPress Update page found at Dashboard > Updates. (If you』re using WordPress Multisite, visit your 「Network Admin」 updates page.)
After upgrading, BuddyPress should prompt you to run the update wizard.
Update prompt
Click on this link.
You should now see the BuddyPress Update wizard. The first step details how BuddyPress now uses the new WordPress Toolbar instead of the older BuddyBar.
First step of BuddyPress Update Wizard
If you do not want to use the WP Toolbar, select the checkbox and click on 「Save & Next」.
Now finish the update process by clicking on the submit button for steps 2 and 3.
Congratulations! Go get yourself a pizza pie, you just updated to BuddyPress 1.6!
Important Changes to Know
There are a few things that have changed in BuddyPress 1.6 that may affect the functionality of your website; these changes are noted below.
I see the WordPress Toolbar. I like the older BuddyBar. How do I use the BuddyBar instead?
In BuddyPress 1.6, the decision was made to default the admin bar to use WordPress』 Toolbar.
If you disabled the WP Toolbar during the update process, you should be good to go!
If you somehow bypassed this step, don』t fret! It』s still possible to use the older BuddyBar by adding the following code snippet to /wp-content/plugins/bp-custom.php:
// disable the WP Toolbar and revert back to the BuddyBar
add_filter( 'bp_use_wp_admin_bar', '__return_false' );
Help! Where did the BuddyPress settings page go?
In BuddyPress 1.6, the decision was made to move the main BuddyPress admin page to 「Settings > BuddyPress」 and the Profile Fields admin page to 「Users > Profile Fields「.
To read the reason why, click here.

安装群组和全站论坛 (v1.5)

安装群组和全站论坛 (v1.5)

Codex Home → Legacy Docs → Archived Section: Getting Started → Installing Group and Sitewide Forums (v1.5)
Installing Group and Sitewide Forums (v1.5)

Archived file. Good only up to BP 1.5 version

A step-by-step illustrated guide for installing the Group and/or Sitewide Forums (bbPress 2.0) for BuddyPress 1.5+ on WordPress 3.2.1 after completing the BuddyPress installation wizard.
Forums Setup
Forums in BuddyPress make use of the bbPress software to function and we made it easy for you to install from the wp-admin backend with a few clicks. Depending on your community』s requirements, you can choose to:

Set up new Forums for Groups only (internal bbPress setup),
Use Existing Installation of Forums for Groups only (internal bbPress setup – upgrading from BP 1.2+),
Set up Sitewide Forums only (integration with bbPress 2.0+ plugin – new in BP 1.5), or
Set up Forums for Groups and Sitewide Forums

Forums FAQ』s (Frequently Asked Questions)
What』s the difference between Forums for Groups and Sitewide Forums?
Forums for Groups:
Give each individual group its own discussion forum. Choose this if you』d like to keep your members』 conversations separated into distinct areas. You may use an existing bbPress installation if you have one.
Features:

Group Integration
Member Profile Integration
Activity Stream Integration
@ Mention Integration

In other words, the bbPress Forums for Groups in BuddyPress are fully integrated and attached to Groups instead of the categorical and hierarchical format available in the bbPress Sitewide Forums. The Group/Site/Super Admin has to enable the forum feature in the Group』s admin panel first.
Site Wide Forums:
Your site will have central forums that are not isolated to any specific group. Choose this if you』d like to have a central forum area for your members.
Features:

Central Discussion Area
Forum Plugins Available
Activity Stream Integration
@ Mention Integration

A. Installing Forums for Groups only
Step 1. Go to admin dashboard > BuddyPress > Forums. Click on "Install Group Forums"

Step 2. New bbPress Installation. You』ve decided to set a new bbPress for forum management in BuddyPress. This is very simple and is usually just a one click process. When you』re ready, hit the link below. Click on "Complete Installation"

Step 3. All done! Configuration settings have been saved to the file bb-config.php in the root of your WordPress install.

If you kept the original page name/slug, Forums, for your Group Forums during the Installation Wizard then just proceed to http://yoursite.com/forums and you』ll find the Group Forums Directory page.
If you changed the page name/slug to e.g. 「Our Forums」 by creating a new Page named 「Our Forums」 then associated it with the Discussion Forums in BuddyPress > Pages, re-run Dashboard > Settings > Permalinks > Save, then proceed to http://yoursite.com/our-forums
B. Use Existing Installation of Forums for Groups only
Step 1. If you already have an existing bbPress installation for Groups, go to admin dashboard > BuddyPress > Forums and click on "Use Existing Installation"

Step 2. Existing bbPress Installation
BuddyPress can make use of your existing bbPress install. Just provide the location of your bb-config.php file, and BuddyPress will do the rest. bb-config.php file location: (shows path where bb-config.php is expected to be found) Click on "Complete Installation"

Step 3. If the path to your existing bb-config.php was incorrect, you』ll receive an error message 「The bb-config.php file was not found at that location, please try again.」 Find where that bb-config.php is and make sure you have the right path when you go through the process again.
If the path to your existing bb-config.php is correct, you』ll receive a congratulatory message and you can proceed to home page and test drive your Group Forums.
Pages: 1 2 3 4

BP_User_Query

BP_User_Query

Codex Home → Developer Resources → BP_User_Query
BP_User_Query

BP_User_Query Class
The BP_User_Query class was introduced in BuddyPress 1.7 as part of making BuddyPress more scalable. The class lives in buddypress/bp-core/classes/class-bp-user-query.php.  Review the current class for additional arguments not listed here, such as:  member types and xprofile_query.

Accepted Parameters

type (optional)
Defines the type of users to return.

Accepted arguments: active, newest, popular, online, alphabetical, random
Default value: 'newest'

per_page (optional)
The number of users to display on a page before they are paginated to the next page.

Default value: 0

page (optional)
The page offset (together with per_page).

Default value: 1

user_id (optional)
Pass a single numeric user id to limit results to friends of that user. Requires the Friends component.

Default value: 0

search_terms (optional)
Terms to search by. Search happens across xprofile fields. Requires XProfile component.

Default value: false

include (optional)
An array or comma-separated list of user ids. Results will be limited to users in this list.

Default value: false

exclude (optional)
An array or comma-separated list of user ids. Results will not include any users in this list.

Default value: false

user_ids (optional)
An array or comma-separated list of user ids. When this parameter is passed, it will override all other parameters. BP User objects will be constructed using these IDs only. So the order of the ids will be preserved in the results.

Default value: false

meta_key (optional)
Limit results to users that have usermeta associated with this meta_key. Usually used with meta_value.

Default value: false

meta_value (optional)
When used with meta_key, limits results to users whose usermeta value associated with meta_key matches meta_value.

Default value: false

populate_extras (optional)
Boolean. Fetch extra meta for each user such as their full name, if they are a friend of the logged in user, their last activity time.

Default value: true

count_total (optional)
Determines how BP_User_Query will do a count of total users matching the other filter criteria. Default value is 『count_query』, which does a separate SELECT COUNT query to determine the total. 『sql_count_found_rows』 uses SQL_COUNT_FOUND_ROWS and SELECT FOUND_ROWS(). Pass an empty string to skip the total user count query.

Default value: 'count_query'

Usage
This class is called by functions like bp_has_members() via bp_core_get_users().
You can create your own instance [ TO-DO: create a why and how example ].
But usually you』ll just want to manipulate the parameters.
You can do that by using this hook in the class:
do_action_ref_array( 'bp_pre_user_query_construct', array( &$this ) );
//$this is a reference to the parameter array

Code Examples
Here』s an example using the bp_pre_user_query_construct hook. This example will affect the display of members on the Members page by not showing any of the members whose ids are in $this->custom_ids. It will not affect the display of members on pages like .../groups/some-group/members/ or in widgets, etc. We use the bp_before_directory_members hook instead of one of the other hooks, like bp_before_members_loop, because we want to adjust the 『All Members』 count too. Using this approach, we do not have to touch any template files.
class BP_Custom_User_Ids {

private $custom_ids = array();

public function __construct() {

$this->custom_ids = $this->get_custom_ids();

add_action( 'bp_pre_user_query_construct', array( $this, 'custom_members_query' ), 1, 1 );
add_filter( 'bp_get_total_member_count', array( $this, 'custom_members_count' ), 1, 1 );

}

private function get_custom_ids() {
global $wpdb;

// collection based on an xprofile field
$custom_ids = $wpdb->get_col("SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 8 AND value = 'no'");

return $custom_ids;
}

function custom_members_query( $query_array ) {

$query_array->query_vars['exclude'] = $this->custom_ids;

//in case there are other items like widgets using the members loop on the members page
remove_action( 'bp_pre_user_query_construct', array( $this, 'custom_members_query' ), 1, 1 );

}

function custom_members_count ( $count ) {

$new_count = count( $this->custom_ids );
return $count - $new_count;

}
}

function custom_user_ids( ) {

new BP_Custom_User_Ids ();

}
add_action( 'bp_before_directory_members', 'custom_user_ids' );

Preserve the Order
Have you ever wanted to preserve the order of ids passed into the members loop? Now you can by using the 『user_ids』 parameter:
function custom_members_query( $query_array ) {
$query_array->query_vars['user_ids'] = $this->custom_ids;
}

NB: the 『user_ids』 parameter will break pagination in versions less than BP 1.9. Ticket & Patch

Additional Resources
class BP_Group_Member_Query extends BP_User_Query
In most situations, bp_parse_args() is a better and easier approach to filtering members: Using bp_parse_args() to filter BuddyPress template loops/

从旧论坛迁移到 bbPress 2.2+

从旧论坛迁移到 bbPress 2.2+

Codex Home → Getting Started → User Submitted Guides → Migrating from old forums to bbPress 2.2+
Migrating from old forums to bbPress 2.2+

So you』ve been using BuddyPress』 built-in group forums since BuddyPress 1.5, but would like to use the new bbPress plugin to power your forums instead.
Gotcha.  You』ll need to migrate your existing group forum content over to bbPress as well.  Don』t worry!  This is what this article is all about.
Let』s get started!
(1) Backup your database
It』s always wise to backup your database, just in case you need to restore your database backup if migration fails.
(2) Install bbPress 2.3 or higher (if you』re using bbPress 2.2, upgrade to 2.3)
Install bbPress and activate it.
Also make sure you』re using at least BuddyPress 1.6.1.
(3) Remove 「Forums」 page from BuddyPress

In the the WP admin dashboard navigate to 「Settings > BuddyPress「.  Click on the 「Pages」 tab.
Under 「Discussion Forums「, select 「None」 and save.

(4) Disable BuddyPress』 Forums Component

In the WP admin dashboard, navigate to 「Settings > BuddyPress「.  Click on the 「Components」 tab.
Uncheck 「Group Forums (Legacy)」 and save.

(5) Import old forums to bbPress 2

In the WP admin dashboard, navigate to 「Tools > Forums「
(Note: if using Members plugin, you may need to assign forum capabilities to the Administrator Role. Go to Users->Roles.)
Click on the 「Import Forums」 tab.
Under 「Select Platform」, make sure 「bbPress1」 is selected.
For 「Database Name」, 「Database User」, 「Database Password」, use the values as set in wp-config.php.
Under 「Table Prefix」, type in your bbPress prefix. For most users, this will be 「wp_bb_「, however if you used a different table prefix, check your table prefix in bb-config.php and append 「bb_」 to whatever is listed there.
Click on the 「Start」 button.

(6) Repair bbPress 2 forum relationships

In the WP admin dashboard, navigate to 「Tools > Forums「
Check the first option and hit 「Repair「.
Next, check the second option and hit 「Repair「.  Keep doing this until you have completed each option on this page.

(7) Configure bbPress settings for BuddyPress

In the WP admin dashboard, navigate to 「Settings > Forums「
Make sure 「Enable Group Forums」 is checked
Under 「Group Forums Parent「, ensure 「Group Forums」 is selected.

(8) Make 「Forums」 page a sitewide index (optional)

In the WP admin dashboard, navigate to 「Pages「
Find your old BuddyPress forums page (usually named 「Forums」) and edit that page.
In the post content, type in `[bbp-topic-index]`
This will use bbPress』 topic index shortcode to display the most recent topics on our forums page.
For more on bbPress shortcodes, check out the codex article.

创建插件

创建插件

Codex Home → BuddyPress Plugin Development → Creating a Plugin
Creating a Plugin

This article goes through the steps you need to follow, and things to consider when creating a well-structured BuddyPress Plugin.
Plugin Name
The first task in creating a BuddyPress Plugin is to think about what the Plugin will do, and make a (hopefully unique) name for your Plugin. Check out Plugins and the other repositories it refers to, to verify that your name is unique; you might also do a Google search on your proposed name. Most Plugin developers choose to use names that somewhat describe what the Plugin does; for instance, a weather-related Plugin would probably have the word 「weather」 in the name. The name can be multiple words.
Plugin Files
The next step is to create a PHP file with a name derived from your chosen Plugin name. For instance, if your Plugin will be called 「Fabulous Functionality」, you might call your PHP file fabfunc.php. Again, try to choose a unique name. People who install your Plugin will be putting this PHP file into the BuddyPress Plugin directory in their installation, wp-content/plugins/, so no two Plugins they are using can have the same PHP file name.
Another option is to split your Plugin into multiple files. Your BuddyPress Plugin must have at least one PHP file; it could also contain JavaScript files, CSS files, image files, language files, etc. If there are multiple files, pick a unique name for a file directory and for the main PHP file, such as fabfunc and fabfunc.php in this example, put all your Plugin』s files into that directory, and tell your Plugin users to install the whole directory under wp-content/plugins/. However, an installation can be configured for wp-content/plugins to be moved, so you must use plugin_dir_path() and plugins_url() for absolute paths and URLs. See: http://codex.BuddyPress.org/Determining_Plugin_and_Content_Directories for more details.
In the rest of this article, 「the Plugin PHP file」 refers to the main Plugin PHP file, whether in wp-content/plugins/ or a sub-directory.
Readme File
If you want to host your Plugin on https://wordpress.org/extend/plugins/, you also need to create a readme.txt file in a standard format, and include it with your Plugin. See https://wordpress.org/extend/plugins/about/readme.txt for a description of the format.
Note that the WordPress plugin repository takes the 「Requires」 and 「Tested up to」 versions from the readme.txt in the stable tag.
Home Page
It is also very useful to create a web page to act as the home page for your BuddyPress Plugin. This page should describe how to install the Plugin, what it does, what versions of BuddyPress it is compatible with, what has changed from version to version of your Plugin, and how to use the Plugin.
File Headers
Now it』s time to put some information into your main Plugin PHP file.
Standard Plugin Information
The top of your Plugin』s main PHP file must contain a standard Plugin information header. This header lets BuddyPress recognize that your Plugin exists, add it to the Plugin management screen so it can be activated, load it, and run its functions; without the header, your Plugin will never be activated and will never run. Here is the header format:

The minimum information BuddyPress needs to recognize your Plugin is the Plugin Name line. The rest of the information (if present) will be used to create the table of Plugins on the Plugin management screen. The order of the lines is not important.
So that the upgrade mechanism can correctly read the version of your plugin it is recommended that you pick a format for the version number and stick to it between the different releases. For example, x.x or x.x.x or xx.xx.xxx
The License slug should be a short common identifier for the license the plugin is under and is meant to be a simple way of being explicit about the license of the code.
Important: file must be in UTF-8 encoding.
License
It is customary to follow the standard header with information about licensing for the Plugin. Most Plugins use the GPL2 license used by BuddyPress or a license compatible with the GPL2. To indicate a GPL2 license, include the following lines in your Plugin:

Programming Your Plugin
Now, it』s time to make your Plugin actually do something. This section contains some general ideas about Plugin development, and describes how to accomplish several tasks your Plugin will need to do.
BuddyPress Plugin Hooks
Many BuddyPress Plugins accomplish their goals by connecting to one or more BuddyPress Plugin 「hooks」. The way Plugin hooks work is that at various times while BuddyPress is running, BuddyPress checks to see if any Plugins have registered functions to run at that time, and if so, the functions are run. These functions modify the default behavior of BuddyPress.
Template Tags
Another way for a BuddyPress Plugin to add functionality to BuddyPress is by creating custom Template Tags. Someone who wants to use your Plugin can add these 「tags」 to their theme, in the sidebar, post content section, or wherever it is appropriate. For instance, a Plugin that adds geographical tags to posts might define a template tag function called geotag_list_states() for the sidebar, which lists all the states posts are tagged with, with links to the state-based archive pages the Plugin enables.
To define a custom template tag, simply write a PHP function and document it for Plugin users on your Plugin』s home page and/or in the Plugin』s main PHP file. It』s a good idea when documenting the function to give an example of exactly what needs to be added to the theme file to use the function, including the .

老旧文档

老旧文档

Codex Home → Legacy Docs
Legacy Docs

This section is a historical collection of documents that are now outdated or superseded by the articles for BuddyPress 2.0.0 and above.
You can find the links to the legacy documents for versions BuddyPress 2.0.0 or lower compiled at the sidebar.

安装 BuddyPress 主题

安装 BuddyPress 主题

Codex Home → Getting Started → Customizing → Installing BuddyPress Themes
Installing BuddyPress Themes

Themes for BuddyPress are available at:
https://wordpress.org/extend/themes/tags/buddypress
Make sure that the theme tagged as 「buddypress」 is compatible with the BP/WP version activated in your server.
As of BuddyPress 1.7, BuddyPress works with most any WordPress out of the box. BuddyPress 1.7 includes base template files that should fit into any WordPress theme without any need to edit code as in previous versions of BuddyPress. Themes that are tagged or suggest they are BuddyPress themes are to be considered themes that have enhanced or customized the base template files that come bundled in the BuddyPress plugin.
If you need reference to the bp-default theme previously bundled with BuddyPress please visit the legacy docs section of the codex. (legacy docs)