bp_ajax_querystring()

bp_ajax_querystring()

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

You can filter the output of the Activity loop using bp_ajax_querystring. Read about other queries you can pass the activity stream and learn more about the Activity loop here.
function filtering_activity_default( $query ) {
if ( empty( $query ) && empty( $_POST ) ) {
$query = 'action=activity_update';
}
return $query;
}
add_filter( 'bp_ajax_querystring', 'filtering_activity_default', 999 );

 
To filter ajax:
function my_bp_loop_querystring( $query_string, $object ) {
if ( ! empty( $query_string ) ) {
$query_string .= '&';
}

$query_string .= 'per_page=2';

return $query_string;
}
add_action( 'bp_legacy_theme_ajax_querystring', 'my_bp_loop_querystring', 20, 2 );

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

老旧文档

老旧文档

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.

安装向导

安装向导

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

将 bbPress 2.2+ 与 BuddyPress 一起使用

将 bbPress 2.2+ 与 BuddyPress 一起使用

Codex Home → Legacy Docs → Archived Section: Getting Started → Using bbPress 2.2+ with BuddyPress
Using bbPress 2.2+ with BuddyPress

Archived file. Good up to BP 1.6.5

Recently, bbPress 2.2+ introduced support for BuddyPress.
However, BuddyPress already has a Discussion Forums component that is packaged with the plugin.
We don』t recommend that you use both bbPress and BP』s Discussion Forums at the same time.  So which one should you use?
For most users, we recommend bbPress. bbPress is more flexible, more robust, and more actively developed.
If you already have both the BP』s Discussion Forums component and bbPress enabled, you have a few options:

Migrate your BP Discussion Forums content to bbPress (preferred)
Keep using BP Discussion Forums and disable bbPress
Use BuddyPress』 built-in forums and bbPress at the same time

Approach 1: Migrate BP Discussion Forums to bbPress (preferred)
There are a couple of reasons why you might want to consider migrating to the bbPress plugin:

bbPress is being actively developed; the 「Discussion Forums」 component in BuddyPress is retiring as of BuddyPress 1.7. The retired component will continue to work, but no new features will be incorporated by the BuddyPress team.
bbPress has a bunch of cool features that BP Discussion Forums doesn』t: extensive moderation via the WP admin dashboard, topic splitting, revisions, spam management, favorites, subscriptions, and more.

If you』d like to convert your BuddyPress built-in forums to use bbPress, follow this guide:
https://codex.buddypress.org/buddypress-site-administration/migrating-from-old-forums-to-bbpress-2/
If you have any questions with this guide, please post in our support forum:
https://buddypress.org/support
Approach 2: Keep using BuddyPress』 built-in forums
This approach is easy. Just deactivate bbPress and keep using BuddyPress』 built-in forums.
The reason why you might want to do this is if you』ve already made large customizations to your BuddyPress group forums and you don』t feel an immediate need to use the bbPress plugin.
If you have a relatively, new BuddyPress install, it is recommended to follow approach 1.
Approach 3: Use both BuddyPress』 built-in forums and bbPress together
If you』ve already configured both BuddyPress and bbPress to work alongside each other and you know why you want both forums, that』s OK too.

安装 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)

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

bp_get_the_profile_field_value()

bp_get_the_profile_field_value()

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

Profile fields have a filter that adds a link to certain words that are used to search members with. To remove this filter:
remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );

Source File
bp_get_the_profile_field_value() is located in bp-xprofile/bp-xprofile-template.php

Twenty Eleven 二〇一七主题

Twenty Eleven 二〇一七主题

Codex Home → BuddyPress Theme Development → BP Theme Compatibility and the WordPress Default Themes → Twenty Eleven Theme
Twenty Eleven Theme

A. One Column Layout
This is the default page layout of the Twenty Eleven theme. There』s no need to do anything else if this is the layout you prefer for all your BuddyPress pages.
B. Full-width page
Full-width Layout. Click on image to enlarge.If you prefer to have a full-width layout for all your BuddyPress pages, follow the steps laid out below.
1. Create a child theme of the Twenty Eleven theme.
2. Create a new file in your new child theme folder and name it buddypress.php.
3. Copy over the content of Twenty Eleven』s onecolumn-page.php file into the new buddypress.php file

5. Open up your child theme』s style.css file and add the following and save file.
.buddypress .entry-header,
.buddypress .entry-content,
.buddypress footer.entry-meta {
margin: 0 auto !important;
width: 100% !important;
}

6. Upload your Twenty Eleven child theme folder to server.
C. Two Column, Right Sidebar Layout
Two-column Layout. Click on image to enlarge.If you prefer to have a two column layout for all your BuddyPress pages, follow the steps below.
1. Create a child theme of the Twenty Eleven theme.
2. Create a new file in your new child theme folder and name it buddypress.php.
3. Copy over the content of Twenty Eleven』 theme』s sidebar-page.php file into the new buddypress.php file.

4. Create a functions.php file in the folder of your child theme if you don』t have one yet. You will need to remove the .singular body class generated via Twenty Eleven theme』s functions.php file for the regular pages, which is designed as a one column layout. Otherwise, the sidebar you will be adding will fall down below the BuddyPress content.
5. Add the following to your new functions.php file then save file.
$value) {
if ($value == 'singular') unset($wp_classes[$key]);
}
endif;
return $wp_classes;
}
add_filter('body_class', 'mme_remove_singular_body_class', 20, 2);

6. Upload your Twenty Eleven child theme folder to server.

安装群组和全站论坛 (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

模板包演练 - 二〇一二 Twenty Twelve 主题

模板包演练 - 二〇一二 Twenty Twelve 主题

Codex Home → Legacy Docs → Archived Section: Theme Development → Themes & the BuddyPress Template Pack → Template Pack Walkthrough – Twenty Twelve
Template Pack Walkthrough – Twenty Twelve

Archived file. Good only up to BP 1.6.5 version

BP TEMPLATE PACK 1.2.1 == BUDDYPRESS 1.6.3 == WORDPRESS 3.5

There are two ways to implement Step Three of the compatibility process:
– First Method: Superimposing the HTML structure of your WordPress theme onto 17 BP template files which were transferred into your WP theme folder during the compatibility process or
– Second Method: Creating the following files in your WordPress theme – header-buddypress.php, sidebar-buddypress.php and/or footer-buddypress.php
We』ll use the second method to make Twenty Twelve compatible with BuddyPress. By the end of this article, you should have the basic child theme files required to make Twenty Twelve compatible with BP 1.6.3 using the BP Template Pack plugin:

/bp-twentytwelve/

header-buddypress.php
sidebar-buddypress.php
style.css

Prelude: Create a Twenty Twelve Child Theme
( If you already have your own Twenty Twelve Child theme, skip this section and proceed to the Compatibility Process )
1. Create a new theme folder for your Twenty Twelve child theme. For this example, the child theme is called BP Twenty Twelve so we』ll name our theme folder bp-twentytwelve.
2. Create a style.css file and add it in the bp-twentytwelve folder with content below:
/*
Theme Name: BP Twenty Twelve
Theme URI: https://codex.buddypress.org/
Description: Twenty Twelve child theme for BuddyPress 1.5 Compatibility Process
Version: 1.0
Author: mercime
Author URI: https://codex.buddypress.org/
Template: twentytwelve
Tags: buddypress, two-column
*/
@ import url( ../twentytwelve/style.css );

Note: remove the space between 「@」 and 「import」 above to implement the CSS import
3. Upload the bp-twentytwelve folder with the style.css file within to your server to /wp-content/themes/
N.B. We』ll be creating and uploading more files later during the compatibility process. For now, these are the basic files required for the child theme to be activated so that we can proceed with the BP compatibility process.
Compatibility Process
1. After activating BuddyPress, go to dashboard Appearance > Themes and activate our child theme 「BP Twenty Twelve」. At the top of the Themes panel, you』ll see a message with 3 different options to make your theme compatible with BuddyPress. Select the link 「update your existing WordPress theme"
2. Clicking on the above link will bring you to the 「Install Plugins」 panel. Click on the 「Install」 link under BuddyPress Template Pack plugin.
3. Click 「OK」 to install BuddyPress Template Pack plugin.
4. In the next panel, click on the link 「Activate」 to activate the BP Template Pack plugin.
5. Go to Appearance > BP Compatibility
6. Step One: Moving template files automatically. Click on 「Move Template Files」
7. If the process was successful, you』ll get the message 「Templates moved successfully!」 in the same panel. Click on the button」Continue to Step Three." You will only need to go through Step Two if there was a problem transferring the files.
8. Step Three: Tweaking your layout – using the second method – Xfiles-buddypress.php.

Text available here.
a) Compare the HTML structure of Twenty Twelve theme』s page.php or index.php with a BP template file like /activity/index.php.
bp-default theme has a two-column layout with sidebar

[ CONTENT ]

Twenty Twelve』s page.php also has a two-column layout with sidebar

[ CONTENT ]

Both bp-default activity/index.php and Twenty Twelve page.php have a two-column layout with sidebar and a common div#content. We』ll wrap Twenty Twelve』s page structure around the content of the BP template files then use style.css to finish the look of the layout.
We only need to create two more files – header-buddypress.php and sidebar-buddypress.php – for this child theme. Because of the similarity in structure, there』s no need to create a footer-buddypress.php.
b) Open up header.php of the Twenty Twelve theme. Add the following at the bottom of the file and Save As header-buddypress.php :

c) Open up sidebar.php of the Twenty Twelve theme. Add the following at the top of the file and Save As > sidebar-buddypress.php :

//
jQuery(document).ready( function() {
if ( jQuery('div#blog-details').length && !jQuery('div#blog-details').hasClass('show') )
jQuery('div#blog-details').toggle();
jQuery( 'input#signup_with_blog' ).click( function() {
jQuery('div#blog-details').fadeOut().toggle();
});
});

//

d) Upload header-buddypress.php and sidebar-buddypress.php to wp-content/themes/bp-twentytwelve/
9. Congratulations, you have completed the BuddyPress Theme compatibility setup procedure! Click on Save Settings

Finishing Touches
We』re almost done. Check out the layout of the BP components in your site.
We need to clean up some styles enqueued by the BP Template Pack plugin. Open up the child theme』s style.css and add this block after the text we』ve already posted in the file:
/ > BuddyPress Component Finishing Styles
--------------------------------------------------- */

table.forum {
margin: 0 !important;
}
table.forum tr > td:first-child, table.forum tr > th:first-child {
padding: 15px !important;
}
div#item-header h2,
form#whats-new-form h5 {
clear: none !important;
}
div#item-header ul {
list-style-type: none;
}
div.dir-search {
margin: -20px 0 0 !important;
}
div.item-list-tabs {
margin: 25px 0 20px !important;
}
div.item-list-tabs ul,
div#object-nav.item-list-tabs ul,
div#subnav.item-list-tabs ul {
font-size: 13px;
margin-left: 0 !important;
}
div.item-list-tabs ul li:first-child {
margin-left: 15px !important;
}
div#subnav.item-list-tabs {
margin: -15px 0 15px !important;
}
#activity-stream {
margin-left: 0;
}
.padder div.pagination {
margin: -20px 0 0 !important;
}
ul.item-list {
list-style-type: none;
margin-bottom: 20px;
margin-left: 0;
}
body.activity-permalink div.activity {
padding: 20px;
}
body.activity-permalink .activity-content {
padding: 0 !important;
}
.widget-container {
overflow: hidden;
}
ul#members-list,
ul#groups-list {
list-style-type: none;
margin-left: 0;
}
div.avatar-block img {
float: left;
}
#content input, #content textarea {
font-size: 12px;
line: height: 18px;
}
#main {
margin-bottom: 20px;
}

Add and delete styles according to taste. Save file and upload to child theme』s folder wp-content/themes/bp-twentytwelve/ and WE ARE DONE.