安装群组和全站点论坛

安装群组和全站点论坛

Codex Home → Getting Started → Installing Group and Sitewide Forums
Installing Group and Sitewide Forums

For New Installations:
The following is a step-by-step guide for installing the Group and/or Sitewide Forums  for the latest BuddyPress and bbPress plugins.
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 Sitewide Forums only
Set up Group and Sitewide Forums
Set up Group Forums only

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. bbPress Forums for Groups in BuddyPress are fully integrated and attached to Groups. The Group Admin has to enable the forum feature in the Group』s admin panel first.
Features:

Group Integration
Member Profile Integration
Activity Stream Integration
Forum Plugins Available
@ Mention Integration

Site Wide Forums
Your site will have 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
Member Profile Integration
Forum Plugins Available
Activity Stream Integration
@ Mention Integration

From hereon forward, you』ll be using the bbPress plugin to set up your Group and/or Sitewide Forums.
A. Set Up Sitewide Forums only

Install and activate bbPress.
Proceed to bbPress.org Codex to get started in creating your Sitewide Forums.
If you kept the default 「forums」 slug in Settings > Forums, you can create a new Page via Pages > Add New. Add Title 「Forums」 and insert the forums index shortcode and/or other bbPress shortcode you』ll find in the bbPress Codex then publish the new page.
Add new 「Forums」 Page in your custom menu via Appearances > Menu.

B. Set Up Group and Sitewide Forums

Install and activate bbPress.
Proceed to bbPress.org Codex to get started in creating your Sitewide Forums.
If you kept the default 「forums」 slug in Settings > Forums, you can create a new Page via Pages > Add New.
Add Title 「Forums」 and insert the forums index shortcode and/or other bbPress shortcode you』ll find in the bbPress Codex.
Publish the new page.
Add new 「Forums」 Page in your custom menu via Appearances > Menu.
Create a new Forum as the 「parent forum」 for all of your Group Forums.

Go to Forums > New Forum
Add Title, e.g. Group Forums
Change Forum Attribute Type from 「Forum」 to 「Category」

Add Page Order, e.g. 100 – positioning Group Forums near bottom of Sitewide Forums. Leave it at default 「0」 if you want it to show up above all other forums. Or adjust Page Order as necessary.
Click on Publish button.

Set up BuddyPress Group Forums in bbPress Settings

Go to Settings > Forums and scroll down to the BuddyPress section
Enable Group Forums – make sure it』s checked
Group Forums Parent – select 「Group Forums」 created in #2 above or whatever you chose to name the Forum
Save Settings

Create a Group and set up Group』s Forum

Go to your site』s Group』s Directory Page and click on create Group button.
Go through the group creation process. In Step 3, check 「Yes, I want this group to have a forum.」
Continue through and finish the group creation process.
The 「Forum」 link is now visible in the Group』s main navigation and you and your members can now create new topics for your group』s forums.

C. Set Up Group Forums Only

Install and activate bbPress.
Go to admin dashboard menu Forums > New Forum

Add Title, e.g. Group Forums
Change Forum Attribute Type from 「Forum」 to 「Category」
Click on Publish button.

Go to admin dashboard menu Settings > Forums to configure Forum Settings

BuddyPress -> Enable Group Forums: Check 「Allow BuddyPress Groups to have their own forums」
BuddyPress -> Group Forums Parent: Select 「Group Forums」 category forum created in previous step.
Click on Save button.

Create a Group and set up Group』s Forum

Go to your site』s Group』s Directory Page and click on create Group button.
Go through the group creation process. In Step 3, check 「Yes, I want this group to have a forum.」
Continue through and finish the group creation process.
The 「Forum」 link is now visible in the Group』s main navigation and you and your members can now create new topics for your group』s forums.

D. Forums: Frequently Asked Questions
How can I migrate my Group Forums to the Sitewide Forums?
Please see the main article Migrating from old forums to bbPress 2.2+.
I installed this cool bbPress add-on plugin. Will it work with the Group Forums I set up with bbPress?
Yes.

? Getting Started

群组扩展 API

群组扩展 API

Codex Home → Developer Resources → Group Extension API
Group Extension API

Note: This guide is for use with BuddyPress 1.8+. A guide for using the Group Extension API with earlier versions of BP can be found at https://codex.buddypress.org/developer/plugin-development/group-extension-api-prior-to-bp-1-8/.
The group extension API makes it very easy to add custom creation steps, edit screens, navigation items and pages to a group. It essentially allows you to create fully functional extensions to BuddyPress created groups.
Note: If you are building a BuddyPress plugin, please make sure you have read how to check if BuddyPress is active. This is very important. You might also want to check & ensure that the Group component is active using the bp_is-active() function.
Overview
The Group Extension API consists of a base class called BP_Group_Extension, which you extend in your own plugin. BP_Group_Extension does most of the work necessary to integrate your content into BP group – creating new navigation tabs, registering a step during group creation, etc. See the Examples section for working examples.
Use
Use BP_Group_Extension as follows:

In a plugin file, create your own class that extends BP_Group_Extension.
In the __construct() method, pass an array of arguments to parent::init(). Arguments are described in the Configuration section.
Write any methods that your extension requires. See the Methods section for available options.
Register your extension with BuddyPress using bp_register_group_extension()

 
Configuration
In the __construct() method of your extension class, you should define a set of arguments and pass them to parent::init(). (Reference the examples to see how this is done.) Possible arguments:

slug
(required) A unique string identifier for your extension. Used, among other places, in the construction of URLs.
name
(required) The translatable name of your extension. Used as the default value for navigation items and page titles.
visibility
(optional) 'public' means that your extension will be visible to anyone who can access the group, 'private' means it won』t. Defaults to 'public'. Note: BuddyPress 2.1.0 added the new argument 'access', which should be used when possible.
nav_item_position
(optional) An integer describing where your extension』s tab should appear. A number between 1 and 100 is recommended. Defaults to 81.
enable_nav_item
(optional) true for the nav item to be enabled for the current user, false otherwise. Defaults to true. Note: BuddyPress 2.1.0 added the new argument 'show_tab', which should be used when possible.
nav_item_name
(optional) The string you want to appear in the navigation tab for your group extension. Defaults to the of the 『name』 parameter, described above.
display_hook
(optional) The WordPress action that the widget display method is hooked to. Defaults to 'groups_custom_group_boxes'.
template_file
(optional) The template file that BuddyPress will use as a wrapper for your display content. Defaults to 'groups/single/plugins.php'
screens
(optional) A multi-dimensional array of options related to the three secondary 「screens」 available to group extensions: 『create』 (the step dedicated to the extension during the group creation process), 『edit』 (the subtab dedicated to the extension under the Admin tab of the group), and 『admin』 (the extension』s metabox that appears on the group page when editing via the Groups Administration Dashboard panels). Each of these screens has a set of configuration options, to be described below. Note that all config values are optional, and you only need to override those values where you want to change the default – BuddyPress will parse your 『screens』 array, using your provided values when available, otherwise falling back on the defaults.

create – Config options for the 『create』 screen

position – The position of the extension』s step in the Create a Group process. An integer between 1 and 100 is recommended. Defaults to 81.
enabled – true if you want your extension to have a Create step, otherwise false. Defaults to true.
name – The name of the creation step, as it appears in the step』s navigation tab. Defaults to the general 『name』 value described above.
slug – The string used to create the URL of the creation step. Defaults to the general 『slug』 value described above.
screen_callback – The function BP will call to display the content of your create screen. BuddyPress attempts to determine this function automatically; see Methods below. Do not change this value unless you know what you』re doing.
screen_save_callback – The function BP will call after the extension』s create step has been saved. BuddyPress attempts to determine this function automatically; see Methods below. Do not change this value unless you know what you』re doing.

edit – Config options for the 『edit』 screen

submit_text – The text of the submit button on the edit screen. Defaults to 'Edit'.
enabled – true if you want your extension to have a subtab in the Group Adimn area, otherwise false. Defaults to true.
name – The text that appears in the navigation tab for the extension』s Edit screen. Defaults to the general 『name』 value described above.
slug – The string used to create the URL of the admin tab. Defaults to the general 『slug』 value described above.
screen_callback – The function BP will call to display the content of your admin tab. BuddyPress attempts to determine this function automatically; see Methods below. Do not change this value unless you know what you』re doing.
screen_save_callback – The function BP will call after the extension』s admin tab has been saved. BuddyPress attempts to determine this function automatically; see Methods below. Do not change this value unless you know what you』re doing.

admin – Config options for the 『admin』 screen

metabox_context – The context for your extension』s metabox. Defaults to 'normal'. (See add_meta_box() for more details.)
metabox_priority – The priority for your extension』s metabox. Defaults to ''. (See add_meta_box() for more details.)
enabled – true if you want your extension to have a subtab in the Group Adimn area, otherwise false. Defaults to true.
name – The text that appears in the navigation tab for the extension』s Edit screen. Defaults to the general 『name』 value described above.
slug – The string used to create the URL of the admin tab. Defaults to the general 『slug』 value described above.
screen_callback – The function BP will call to display the content of your admin tab. BuddyPress attempts to determine this function automatically; see Methods below. Do not change this value unless you know what you』re doing.
screen_save_callback – The function BP will call after the extension』s admin tab has been saved. BuddyPress attempts to determine this function automatically; see Methods below. Do not change this value unless you know what you』re doing.

access
(optional) Which users can visit the extension』s tab. Possible values: 'anyone', 'loggedin', 'member', 'mod', 'admin' or 'noone'. ('member', 'mod', 'admin' refer to user』s role in the current group.) Defaults to 'anyone' for public groups and 'member' for private groups. Note that the 'mod' level targets only moderators, so if you want to allow access for group moderators and administrators, specify array( 'mod', 'admin' ). Added in BuddyPress 2.1.0 as a more flexible replacement for 'visibility'.
show_tab
(optional) Which users can see the extension』s navigation tab. Possible values: 'anyone', 'loggedin', 'member', 'mod', 'admin' or 'noone'. ('member', 'mod', 'admin' refer to user』s role in the current group.) Defaults to 'anyone' for public groups and 'member' for private groups. Note that the 'mod' level targets only moderators, so if you want to show the tab to group moderators and administrators, specify array( 'mod', 'admin' ). Added in BuddyPress 2.1.0 as a more flexible replacement for 'enable_nav_item'.

 
Methods
BP_Group_Extension has built-in support for a number of different customization methods, which you can override in your extension as needed.
The most prominent of these methods is display(), which BuddyPress uses to generate the output of the plugin』s main tab. Your display() method should echo markup, which BP will automatically place into the proper template.
For the three 「screen」 contexts – 『create』, 『edit』, and 『admin』 – a flexible system allows you to customize the way that your settings screens work, without unnecessary reproduction of code. Your extension should, at minimum, provide the following two methods:

settings_screen()
Outputs the fallback markup for your create/edit/admin screens
settings_screen_save()
Called after changes are submitted from the create/edit/admin screens. This methods should contain the logic necessary to catch settings form submits, validate submitted settings, and save them to the database.

If your extension requires further customization to one or more of the screens, BuddyPress provides the following methods, which are context-specific:

create_screen()
create_screen_save()
edit_screen()
edit_screen_save()
admin_screen()
admin_screen_save()

If your extension contains any of these methods, BP will use them when appropriate. Otherwise, the generic settings_screen() or settings_screen_save() will be used.
 
Examples
Two examples follow. The first is a very simple (though fully functional) implementation of BP_Group_Extension. The second demonstrates some more advanced customizations.

/**
* The bp_is_active( 'groups' ) check is recommended, to prevent problems
* during upgrade or when the Groups component is disabled
*/
if ( bp_is_active( 'groups' ) ) :

class Group_Extension_Example_1 extends BP_Group_Extension {
/**
* Your __construct() method will contain configuration options for
* your extension, and will pass them to parent::init()
*/
function __construct() {
$args = array(
'slug' => 'group-extension-example-1',
'name' => 'Group Extension Example 1',
);
parent::init( $args );
}

/**
* display() contains the markup that will be displayed on the main
* plugin tab
*/
function display( $group_id = NULL ) {
$group_id = bp_get_group_id();
echo 'What a cool plugin!';
}

/**
* settings_screen() is the catch-all method for displaying the content
* of the edit, create, and Dashboard admin panels
*/
function settings_screen( $group_id = NULL ) {
$setting = groups_get_groupmeta( $group_id, 'group_extension_example_1_setting' );

?>
Save your plugin setting here: <input type="text" name="group_extension_example_1_setting" value="" />
'group-extension-example-2',
'name' => 'Group Extension Example 2',
'nav_item_position' => 105,
'screens' => array(
'edit' => array(
'name' => 'GE Example 2',
// Changes the text of the Submit button
// on the Edit page
'submit_text' => 'Submit, suckaz',
),
'create' => array(
'position' => 100,
),
),
);
parent::init( $args );
}

function display( $group_id = NULL ) {
$group_id = bp_get_group_id();
echo 'This plugin is 2x cooler!';
}

function settings_screen( $group_id = NULL ) {
$setting = groups_get_groupmeta( $group_id, 'group_extension_example_2_setting' );

?>
Save your plugin setting here: <input type="text" name="group_extension_example_2_setting" value="" />

Welcome to your new group! You are neat.
Save your plugin setting here: <input type="text" name="group_extension_example_2_setting" value="" />
<?php
}

}
bp_register_group_extension( 'Group_Extension_Example_2' );

endif;

 
Updated Recommendations for BuddyPress 2.6
Please note: Before BuddyPress 2.6, we recommended checking that the `BP_Group_Extension` class existed before calling it. BP 2.6 introduces class autoloading, so the `BP_Group_Extension` class could be autoloaded even if the groups component isn』t active, which causes problems. For this reason, we now recommend that extensions of the `BP_Group_Extension` class be wrapped in an `if ( bp_is_active( 『groups』 ) )` conditional.

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

会员 (Members)

会员 (Members)

Codex Home → Administrator Guide → Members
Members

BuddyPress makes it easy for you to build your community or social network and establish relationships among members with default components such as Extended Profiles, Activity Streams, Friend Connections, Private Messaging, User Groups, and Blogs (multisite installation only) and major features like Notifications.
The following is an overview of the default membership features using BuddyPress.
Sections

Members Directory
Single Member

Member』s Header
Activity Screens
Profile Screens
Messages Screens
Friends Screens
Groups Screens
Settings Screens

Members Directory
Members Directory. Click on image to enlarge.
Options

Search Members search form
All Members tab – with total number of registered users who have logged in at least once after BuddyPress was activated in the installation.
Selectbox – Show: Last Active (default), Newest Registered, or Alphabetical
List of Members registered in the site including time active stamp, latest status update (if any), and latest post (if any)Additional Information

Latest Status Update (if any)
Latest Post (if any)

Action buttons – visible to logged in members only

Add Friend (friendship request) button or Cancel Friendship Request button

My Friends tab – for logged in users only, has total number of friends you have made in the site Sections

Selectbox – Show: Last Active (default), Newest Registered, or Alphabetical
List of your friends
Cancel Friendship button – shows up in row alongside all members in the list

Member』s Header
Member』s Header Area. Click on image to enlarge.
Sections

Member』s Avatar or Site』s Default Avatar
Member』s Nice Name
Member』s Username
Member』s Latest Status Update (if any)
Action buttons – visible to logged in members only

Add Friend (request friendship) button or Cancel Friendship button (if friendship had already been accepted)
Public Message button – opens up your Activity > Personal screen with the member』s username mentioned, e.g. @cottoncandy, in your Status Update box
Private Message button – opens up your Messages > Compose screen with the member』s username already included

Member Activity

Personal – Shows your activities throughout the site. The status update form and action buttons are visible for logged in member only.Options

Selectbox – Show: Everything (default), Updates, Posts, Comments, Friendships, New Groups, or Group Memberships
Status Update – visible to all logged in members only Options

Text Area box
Post In – Selectbox: Member』s Profile Page or to one of Members』s Groups
Post Update button

Comment button
Reply to Comment link
Favorite button or Remove Favorite button
Delete button

Mentions – Shows a list of all @mentions addressed to you. Action buttons below are visible for logged in member only.Options

Selectbox – Show: Everything (default), Updates, Posts, Comments, Friendships, New Groups, or Group Memberships
Comment button
Reply to Comment link
Favorite button or Remove Favorite button

Favorites – Shows a list of all items you clicked as 「Favorite」. Action buttons below are visible to the member only.Options

Selectbox – Show: Everything (default), Updates, Posts, Comments, Friendships, New Groups, or Group Memberships
Comment button
Reply to Comment link
Favorite button or Remove Favorite button
Delete button

Friends – Shows Activity Streams of your friends. Action buttons below are visible for logged-in members only.Options

Selectbox – Show: Everything (default), Updates, Posts, Comments, Friendships, New Groups, or Group Memberships
Comment button
Reply to Comment link
Favorite button or Remove Favorite button

Groups – Shows the Activity Streams of the groups you』ve joined. Action buttons below are visible to the member only.Options

Selectbox – Show: Everything (default), Updates, New Groups, or Group Memberships
Comment button
Reply to Comment link
Favorite button or Remove Favorite button

Member Profile

View – Shows the profile fields you』ve filled up during registration (Base) and any other additional fields which could have been set up by the Site Admin in other profile group/s.
Edit – Panel where you can revise the fields you』ve filled up before or enter information to profile fields which you haven』t filled up yet. Shown for logged in member only.
Change Avatar – Your avatar will be used on your profile and throughout the site. If there is a Gravatar associated with your account email we will use that, or you can upload an image from your computer – .jpg, .gif or .png format. Shown for the logged in member only.Options

Choose File button (no file chosen)
Upload Image button
In next panel, Crop Image

Member Messages

Inbox – Shows the list of Private Message/s sent to your by members of the site. Visible to the logged in member only.Options

Search Messages
Read Message
Delete Message
Bulk Delete Messages – Select Read, Unread or All Messages

Sent – Shows the list of Message/s you have sent to other members of the site. Visible to the logged in member only.Options
Compose Private Message. Click on image to enlarge.

Search Sent Messages
Read Sent Message
Delete Sent Message
Bulk Delete Sent Messages – Select Read, Unread or All Messages

Compose – Shows a form to send messages. Visible to logged in member only.Input

Send To (Username or Friend』s Name) field
Site Admin Only: Checkbox for 「This is a notice to all users.」
Subject field
Message field
Send Message button

Site Admin Only: Notices – Shows list of Sitewide Notices and date sent via Compose panel. The Admin』s notice will show up in the sidebar for logged in members only who in turn, can click on the 「Close」 link at the end of the notice – hopefully after they』ve read the message first. The following buttons are visible to the Site/Super Admin only.Options

Deactivate (notice) button
Delete (notice) button

Member Friends

Friendships – Shows a list of friendships accepted.Options

Select Order by: Last Active, Newest Registered or Alphabetical
View link to friend』s latest status update.
Cancel Friendship button – Visible to logged in member only.

Requests – Shows list of members who have requested friendship with you by clicking on 「Add Friend」 button in Members Directory Page or in your Profile pages. The following buttons are visible to the member only.Options

Accept button
Accepted – message on screen confirming you have accepted someone』s friendship request
Reject button

Member Groups

Memberships – Shows the list of Groups that you』ve joined.Options

Select Order by: Last Active, Newest Registered or Alphabetical
Leave Group button – only for groups you』ve joined, not in groups you』re the Group Admin of. Visible to logged in member only.

Invitations – Visible to logged in member only.Options

Accept button
Reject button

Member Settings
This whole section section is visible for the respective logged in user and the Super/Site Admin only.

GeneralOptions

Current Password (required to update email or change current password) area
Lost your password? link
Account Email input box
Change Password (leave blank for no change)

New Password area
Repeat New Password area

Save Changes button

Notifications – Each event listed below will trigger notification alerts in the site (bubble in WP Toolbar) and by email by default. You have the option of disabling email notifications for any or all of the events listed.
Email notification: Send Notification when (default setting: Yes):

ActivityOptions

A member mentions you in an update using 「@your-username」 – Yes or No radio button
A member replies to an update or comment you』ve posted – Yes or No radio button

MessagesOptions

A member sends you a new message – Yes or No radio button

FriendsOptions

A member sends you a friendship request – Yes or No radio button
A member accepts your friendship request – Yes or No radio button

GroupsOptions

A member invites you to join a group – Yes or No radio button
Group information is updated – Yes or No radio button
You are promoted to a group administrator or moderator – Yes or No radio button
A member requests to join a private group for which you are an admin – Yes or No radio button

Save Changes button

Delete Account – Shows up if deleting account is enabled by Site AdminOptions

Warning: Deleting your account will delete all of the content you have created. It will be completely irrecoverable.
Checkbox: I understand the consequences.
Delete Account button

bp_get_template_part 过滤器

bp_get_template_part 过滤器

Codex Home → Developer Resources → Filters & Constants Reference → bp_get_template_part Filter
bp_get_template_part Filter

Use the bp_get_template_part filter when you want to filter the template returned by BuddyPress』s bp_get_template_part() function. Your filter should accept three arguments ( $templates, $slug, $name ).
The example below illustrates how you can use the bp_get_template_part filter to change the template that』s used to display the activity tab of a member』s profile.
function my_template_part_filter( $templates, $slug, $name ) {

// check whether the current template being fetched is the activity template. If not, just return the current template
if ( 'members/single/activity' != $slug )
return $templates;

// current template being fetched is the activity template. Replace it with the generic plugins.php template
return bp_get_template_part( 'members/single/plugins' );
}

add_filter( 'bp_get_template_part', 'my_template_part_filter', 10, 3 );

Note: For an actual example of overloading an existing template part from a plugin, see Template Overload from a Plugin
If you want to programmatically supply the content without using a template file  load plugins.php and utilize its display functions. The example below will override the activity template part.
function my_template_filter_init() {

add_action( 'bp_template_title', 'my_filter_template_title' );
add_action( 'bp_template_content', 'my_filter_template_content' );
add_filter( 'bp_get_template_part', 'my_template_part_filter', 10, 3 );

}
add_action('bp_init', 'my_template_filter_init');

function my_template_part_filter( $templates, $slug, $name ) {

if ( 'members/single/activity' != $slug )
return $templates;

return bp_get_template_part( 'members/single/plugins' );
}

function my_filter_template_title() {
echo 'Title';
}

function my_filter_template_content() {
echo 'Content';
}

为依赖 BuddyPress 的插件编写自动化测试

为依赖 BuddyPress 的插件编写自动化测试

Codex Home → Developer Resources → Automated Testing → Writing automated tests for BuddyPress-dependent plugins
Writing automated tests for BuddyPress-dependent plugins

The automated testing suite introduced into BuddyPress after 1.7 make it easy to write unit tests for your BP-dependent plugins. Our implementation assumes that you』ll be writing your plugin tests according to wordpress-plugin-tests method. If you』re new to writing WordPress plugin tests, it』s highly recommended that you use the wordpress-plugin-tests technique (or, even easier, the wp-cli unit-tests scaffold tool.
BuddyPress provides two useful kinds of utilities that your plugin』s tests can take advantage of. We』ll discuss the two utilities briefly, and follow it with a working example.
Note: In this tutorial, we』ll be extending BP』s test suite for use in a plugin. But a similar technique could be used for BP themes, as well as for setting up integration tests for an entire, highly-customized BuddyPress installation.

BuddyPress installation and bootstrapping – If your plugin depends on BuddyPress, then you』ll need to make sure that BuddyPress is installed and running when running your tests. Establishing the proper dependencies manually can be very tricky, because BP』s setup routine requires the installation of custom tables and other important one-time configuration, and it all has to happen in a very specific order in order to have a functioning version of BuddyPress. Luckily, you don』t have to do it manually. Just require buddypress/tests/phpunit/includes/loader.php in a callback function hooked to muplugins_loaded using tests_add_filter() – right before you manually load your own plugin – and BP will make sure that (1) BP gets installed correctly, and (2) BP is fully loaded.
BP_UnitTestCase and data factories – When you use the BP_UnitTestCase class for your test cases, you automatically get access to some helpful utility methods (such as go_to(), which is sensitive to the requirements of BP URLs), as well as the BuddyPress data factories for generating groups, activity, and other BP test data. Does your plugin have additional data factories? Consider building your own _UnitTestCase that extends BP_UnitTestCase.

What follows is an annotated bootstrap.php that demonstrates the best way to take inherit BP』s unit testing tools in your own plugin』s test suite. The plugin in the example can be found at BP-CLI, and the code below is from the file bp-cli/tests/bootstrap.php. You should be able to copy and paste this code into your own tests/phpunit/bootstrap.php file – just change the paths for your plugin loader file, and your optional _UnitTestCase class file.
<?php

// The BP_TESTS_DIR constant is a helpful shorthand for accessing assets later
// on. By defining in a constant, we allow for setups where the BuddyPress
// tests may be located in a non-standard location.
if ( ! defined( 'BP_TESTS_DIR' ) ) {
define( 'BP_TESTS_DIR', dirname( __FILE__ ) . '/../../buddypress/tests/phpunit' );
}

// Checking for the existence of tests/phpunit/bootstrap.php ensures that your version
// of BuddyPress supports this kind of automated testing
if ( file_exists( BP_TESTS_DIR . '/bootstrap.php' ) ) {

// The functions.php file from the WP test suite needs to be defined early,
// because it gives us access to the tests_add_filter() function
require_once getenv( 'WP_TESTS_DIR' ) . '/includes/functions.php';

// Hooked to muplugins_loaded, this function is responsible for bootstrapping
// BuddyPress, as well as your own plugin
function _bootstrap_plugins() {

// loader.php will ensure that BP gets installed at the right time, and
// that BP is initialized before your own plugin
require BP_TESTS_DIR . '/includes/loader.php';

// Change this path to point to your plugin's loader file
require dirname( __FILE__ ) . '/../bp-cli.php';
}
tests_add_filter( 'muplugins_loaded', '_bootstrap_plugins' );

// Start up the WP testing environment
require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php';

// Requiring this file gives you access to BP_UnitTestCase
require BP_TESTS_DIR . '/includes/testcase.php';

// Optional: If your plugin needs its own _UnitTestCase class, include it
// here so that it's available when your testcases are loaded
require dirname( __FILE__ ) . '/bp-cli-testcase.php';
}

主题兼容性 - 自定义

主题兼容性 - 自定义

Codex Home → BuddyPress Theme Development → Theme Compatibility → Theme Compatibility – Customizing
Theme Compatibility – Customizing

BuddyPress 1.7 has built-in theme support. All required elements such as front-end editing are included. This means that all functionality will work, even when a theme has no specific BuddyPress templates or code included with it.
To customize BuddyPress:
The directory wp-content/plugins/buddypress/bp-templates/bp-legacy/ contains the directories buddypress, css and js, and the file buddypress-functions.php.

buddypress contains template files; copy any you want to modify into a directory named buddypress in your theme』s root. eg. /wp-content/themes/mytheme/buddypress/
css contains style sheets; copy any you want to modify into a directory named css in your theme』s root. eg. /wp-content/themes/mytheme/css/

Edit the new files for complete control over BuddyPress display in your theme.
Don』t need theme compatibility?
If you are using a theme that was built for an earlier version of BuddyPress, then your theme already supports BuddyPress and you won』t need BP』s theme compatibility. Your theme can tell BuddyPress not to load the theme compat layer by putting the following line in functions.php:
add_theme_support( 'buddypress' );
For more details, see this post on the BP development blog.

升级为 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.

如何加入私人群组

如何加入私人群组

Codex Home → Member Guide → How To Join a Private Group
How To Join a Private Group

Sections

Groups Directory Page – with example of rejected membership request
Single Group Page – with example of accepted membership request

Groups Directory Page
1. In your site』s Group Directory page, click on the 「Request Membership」 button of the Private Group you want to join.
Click on image to enlarge.
2. You』ll see the 「Request Membership」 text in button change to 「Membership Requested」.
Click on image to enlarge.
3. Your request to join the group is sent to the Private Group』s Admin via email (if enabled) and via notification in the Group Admin』s BuddyPress member navigation in the WordPress Toolbar shown below.

4. When the Group Admin of that private group clicks on the notification link in WP Toolbar or the link in the email notification received, the Group Admin is brought to the private group』s Admin > Requests screen. The Group Admin can either click on the 「Accept」 button or the 「Reject」 button. In this example, the Group Admin will choose to reject the request for group membership.
Click on image to enlarge.
5. The Group Admin sees a confirmation message: 「Group membership request rejected.」
Click on image to enlarge.
6. The member whose request has been rejected receives an email (if enabled) and notification in the WP Toolbar which when opened shows: Membership for group 「name_of_group」 rejected.

Single Group Page
1. If you want to attach a message to the Group Admin when you request membership to join the private group, going to the private group』s home page is the option to choose. Click on the 「Request Membership」 button or on the 「Request Membership」 tab in the private group』s header area.
Click on image to enlarge.
2. A textarea will show up so you could add your message to the Group Admin. Click on the 「Send Message」 button to send the message along with the request for membership in the private group.
Click on image to enlarge.
3. The member requesting membership in the private group sees a confirmation message 「Your membership was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.」
Click on image to enlarge.
4. Your request to join the group is sent to the Private Group』s Admin via email (if enabled) and via notification in the Group Admin』s BuddyPress member navigation in the WordPress Toolbar shown below.

5. When the Group Admin of that private group clicks on the notification link in WP Toolbar or the link in the email notification received, the Group Admin is brought to the private group』s Admin > Requests screen. The message of the member requesting the membership is shown along with the 「Accept」 button or the 「Reject」 buttons. In this example, the Group Admin will choose to accept the request for group membership.
Click on image to enlarge.
6. The Group Admin sees a confirmation message 「Group membership request accepted.」
Click on image to enlarge.
7. The member who applied for membership in the private group receives an email (if enabled) and a notification on site in the WP Toolbar which when clicked on shows: Membership for 「name_of_group」 accepted.

8. When the member who got accepted to the private group clicks on the notification, the member is redirected to the private group』s home page – the private group』s activity screen.
Click on image to enlarge.

⇐ Back to Member Guide