注册和激活页面

注册和激活页面

Codex Home → Getting Started → Register and Activation Pages
Register and Activation Pages

BuddyPress 1.7 auto generates the component pages for you. However, if you have open registration off in the WordPress general settings these pages may not get auto created.
Enable Registration
For users to sign up to your new BuddyPress powered site you will need to enable registration.  Visit  Settings > General in the WordPress admin and make sure you have 「anyone can register」 checked.

For multisite/network installations, navigate to 「My Sites > Network Admin > Settings」 then choose either of the following registration settings available:

Registration is disabled. (default)
User accounts may be registered.
Logged in users may register new sites.
Both sites and user accounts may be registered.

Assign the Pages
After you have enabled registration, you can create the required pages and assign them to the register and activation components. Visit Settings > BuddyPress and then click the Pages tab.

⇐ Getting Started

主题兼容性和模板文件

主题兼容性和模板文件

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

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

会员 (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

配置 BuddyPress

配置 BuddyPress

Codex Home → Getting Started → Configure BuddyPress
Configure BuddyPress

After activating BuddyPress, you will be automatically redirected to the BuddyPress Welcome Screen if this is the first time you』ve activated BuddyPress or if you』ve just upgraded BuddyPress. After taking some time to check out the new features added to the plugin, go to wp-admin menu Settings > BuddyPress > Components to begin configuring your installation.
Settings > BuddyPress > Components
By default, BuddyPress Core and the Members components are enabled (Must-Use).  Extended Profiles, Account Settings, Activity Streams, and Notifications components are activated for you.
You can however, selectively disable/enable any of the components later if you choose to do so by using the same 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.
Notifications
Notify members of relevant activity with a toolbar bubble and/or via email, and allow them to customize their notification settings.
User Groups
Groups allow your users to organize themselves into specific public, private or hidden sections with separate activity streams and member listings.
Site Tracking
Record activity for new posts and comments from your site.

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.

Settings > BuddyPress > Pages
Pages are automatically generated for the BuddyPress components you enabled in the components settings using the default slugs based on the name of each component activated. Make sure that activated components have corresponding pages assigned to each in this panel.

Directories
Associate a WordPress Page with each BuddyPress component directory.

Activity Streams (if activated)
User Groups (if activated)
Members

Registration
Associate WordPress Pages with the following BuddyPress Registration pages if you want to enable registration.

Register
Activate

Settings > BuddyPress > Options

Main Settings

Toolbar: Show the Toolbar for logged out users (default: enabled)
Account Deletion: Allow registered members to delete their own accounts (default: enabled)

Profile Settings

Profile Photo Uploads: Allow registered members to upload avatars (default: enabled)
Cover Image Uploads:  Allow registered members to upload cover images (default: enabled)
Profile Syncing: Enable BuddyPress to WordPress profile syncing (default: enabled)

Groups Settings

Group Creation: Enable group creation for all users (default: enabled)
Administrators can always create groups, regardless of this setting.
Group Photo Uploads: Allow customizable avatars for groups (default: enabled)
Group Cover Image Uploads: Allow customizable cover images for groups (default: enabled)

Activity Settings

Blog & Forum Comments: Allow activity stream commenting on blog and forum posts (default: disabled)
Activity Auto Refresh: Automatically check for new items by viewing the activity stream (default: enabled)

bp_after_setup_theme()

bp_after_setup_theme()

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

bp_after_setup_theme() is where BuddyPress loads the theme functions. If you want to filter actions in functions.php or buddypress-functions.php hook to bp_after_setup_theme().
add_action( 'bp_after_setup_theme', 'bp_load_theme_functions', 1 );

Source File
bp_after_setup_theme() is located in bp-core/bp-core-dependency.php

.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

自动化测试

自动化测试

Codex Home → Developer Resources → Automated Testing
Automated Testing

BuddyPress contains a suite of automated tests. These tests are designed to prevent the accidental introduction – or reintroduction – of bugs. If you are a developer of BuddyPress plugins, or if you are contributing to BuddyPress core, please consider using (and writing!) these tests.
The BuddyPress test system is based on, and uses, the WordPress suite. Before getting started, you are encouraged to read more about how WordPress tests work.
Installation

Set up the WordPress test suite. You』ll need to install PHPUnit, check out the WordPress core test repository, create a blank MySQL database, and set up your wp-tests-config.php file. Follow the instructions in the WordPress contributor handbook to get set up. The WordPress test suite can be located anywhere on your development machine, though it』s recommended that you place it somewhere outside your normal WordPress/BuddyPress development environment.
Check out the BuddyPress Subversion repository. At the moment, we do not plan to distribute the test suite with the .zip download of BuddyPress. To use the BuddyPress test suite, you』ll need to check out BuddyPress trunk from buddypress.trac.wordpress.org.
$ svn co https://buddypress.svn.wordpress.org/trunk buddypress
Please note that your checkout of BuddyPress trunk must be at or beyond revision 6908.
Define WP_TESTS_DIR in your bash profile (optional). The test suite requires an environment variable WP_TESTS_DIR that defines the location of your checkout of the WordPress tests. While it』s possible to define the environment variable each time you run the tests, ie, WP_TESTS_DIR=~/sites/tests/phpunit and then export using export WP_TESTS_DIR, you』ll probably find it useful to set the variable permanently in your bash profile. On OS X or Linux, add the following line to ~/.bashrc:
export WP_TESTS_DIR="/home/bgorges/sites/tests/phpunit"
(changing the path to wherever you installed the WP tests in step 1). To apply these changes, source ~/.bashrc.

Running the tests
Navigate to the tests subdirectory of the BuddyPress plugin folder, and type phpunit. (If you didn』t add WP_TESTS_DIR to your bash profile in step 3 above, you』ll need to define that environment variable inline.) Then:
$ phpunit

如何加入私人群组

如何加入私人群组

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