bp_activity_action_spam_activity()

bp_activity_action_spam_activity()

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

bp_activity_action_spam_activity($activity_id=0) is a function that simply allows you to flag Budddypress Activity, like comments or activity updates as spam.
Source File
bp_activity_action_spam_activity() is located in bp-activity/bp-activity-actions.php

bp_core_get_userlink()

bp_core_get_userlink()

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

Description
Returns a HTML formatted link for a user with the user』s full name as the link text.
Top
Usage

Top
Parameters
$user_id
(integer) User ID to check.
$no_anchor
(bool) Disable URL and HTML and just return full name. Default false.
$just_link
(bool) Disable full name and HTML and just return the URL text. Default false.
Returns
Returns false when there was no match found, and the link text (string) based on passed parameters.
Top
Example

post_author ) ); ?>

Top
Source File
bp_core_get_userlink() is located in bp-members/bp-members-functions.php

群组扩展 API(旧版)

群组扩展 API(旧版)

Codex Home → Legacy Docs → Archived Section: Developer Resources → Group Extension API (legacy)
Group Extension API (legacy)

Archived file. Good only up to BP 1.7 version

Note: This guide is for use with versions of BuddyPress older than 1.8. In BP 1.8, the group extension API was rewritten. Plugins written as described below should continue to work, but for new projects you are highly encouraged to use the 1.8+ methods described on the main Group Extension API Codex page.
The group extension API (1.1+) 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.
Note: The admin_screen() and admin_screen_save() methods are new in BuddyPress 1.7. On earlier versions of BP, they won』t do anything.
The API Syntax
A group extension could be created as a standalone plugin file, or included as code within a plugin that performs other tasks. The core API code is as follows:
if ( bp_is_active( 'groups' ) ) : // Recommended, to prevent problems during upgrade or when Groups are disabled

class My_Group_Extension extends BP_Group_Extension {

function __construct() {
$this->name = 'My Group Extension';
$this->slug = 'my-group-extension';

$this->create_step_position = 21;
$this->nav_item_position = 31;
}

/**
* The content of the My Group Extension tab of the group creation process
*
* Don't need a group creation step? In the __construct() method:
*
* $this->enable_create_step = false;
*/
function create_screen() {
if ( !bp_is_group_creation_step( $this->slug ) )
return false;

/**
* If your extension's Create step shares much of its code with
* its Edit step, you might consider putting shared markup into
* a separate method (such as edit_create_markup()), and then
* call the method here:
*
* $this->edit_create_markup();
*/
?>

The HTML for my creation step goes here.

slug );
}

/**
* The routine run after the user clicks Continue from your creation step
*
* You'll be pulling your data out of the $_POST global. Be sure to
* sanitize as necessary.
*/
function create_screen_save() {
global $bp;

check_admin_referer( 'groups_create_save_' . $this->slug );

/* Save any details submitted here */
groups_update_groupmeta( $bp->groups->new_group_id, 'my_meta_name', 'value' );
}

/**
* The content of the My Group Extension tab of the group admin
*/
function edit_screen() {
if ( !bp_is_group_admin_screen( $this->slug ) )
return false; ?>

name ) ?>

Edit steps here

slug );
}

/**
* The routine run after the user clicks Save from your admin tab
*
* You'll be pulling your data out of the $_POST global. Be sure to
* sanitize as necessary.
*/
function edit_screen_save() {
global $bp;

if ( !isset( $_POST['save'] ) )
return false;

check_admin_referer( 'groups_edit_save_' . $this->slug );

/* Insert your edit screen save code here */

/* To post an error/success message to the screen, use the following */
if ( !$success )
bp_core_add_message( __( 'There was an error saving, please try again', 'buddypress' ), 'error' );
else
bp_core_add_message( __( 'Settings saved successfully', 'buddypress' ) );

bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/' . $this->slug );
}

/**
* Use this function to display the actual content of your group extension when the nav item is selected
*/
function display() {
?>

Welcome to my cool group extension!

The HTML for my admin panel.

name ) ?>

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

enable_nav_item = $this->enable_nav_item();

/* Add this method the end of your extension class */
function enable_nav_item() {
global $bp;

/* You might want to check some groupmeta for this group, before determining whether to enable the nav item */
if ( groups_get_groupmeta( $bp->groups->current_group->id, 'settings_complete' ) )
return true;
else
return false;
}

群组扩展 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.

配置 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)

Codex 标准和指南

Codex 标准和指南

Codex Home → Participate and Contribute → Codex Standards & Guidelines
Codex Standards & Guidelines

If you are considering contributing to the codex this simple guide is here to help you with the formatting of pages and standards & conventions to follow to keep a set appearance to pages.
The Codex is curated by a team of volunteers they will check and verify articles for accuracy and adherence to Codex Standards, this is in order to maintain a consistent quality of article and standard throughout the codex. If you notice any articles of concern or think something is outdated or needs checking please contact one of the team members, if you are sure an article contains content that needs attention you may edit it and add a warning to the top of the article – please see the bottom of this page for markup to be copied and used in such circumstances.
Please note: All entries to the Codex are covered by the GNU General Public Licence. All entries may be edited or altered by other contributors.
Sections

How to Create a New Codex Article
How to Edit/Update an Article in the Codex
Codex General Guidelines
Codex Conventions
Formatting Guide
Adding article header messages

How to Create a New Codex Article

Log in using your WordPress username and password.
Click on the 「Create New Page」 link under the header or click on the 「+New > Page」 link on the WP Toolbar
Add the Title of your article
Add the article metas: Versions, Components, Types and Context. Meta boxes are located on the screen』s right sidebar
Add your article in the appropriate codex section in the Page Attributes meta box under the Context box.
For reference, please go to the BuddyPress Codex Table of Contents which is updated regularly to guide you where to place your article
Add content of your article. Check that it follows the Codex General Guidelines, Codex Conventions, and Formatting guides posted below for your reference
After you』re done, click on the 「Publish」 button

How to Edit/Update an Article in the Codex

Log in using your WordPress username and password
Navigate to the page you want to edit/update
Click on the 「Edit Page」 link under the header of the page or click on the 「Edit Page」 link on the WP Toolbar
After you have made the edit/update, please double-check that the Versions, Components, Types and Context are correct and updated as well
Click on the 「Update」 button in the Publish meta box

General Guidelines
Broad guidelines on writing for the BuddyPress Codex

When writing articles please use the second-person point of view to address the reader. e.g. 「Now navigate to your」 Rather than 「Now navigate to our「
When writing technical articles (functions, actions, etc.) please use the draft template you will find in the dashboard, copy and paste it』s body outline markup to your new post
Please keep styling to a minimum, avoid inline styling of elements unless to provide something like a color highlight if thought necessary to lend further emphasis to a piece of text e.g styling a warning in red Ensure you have backed up your DB. Please use elements sparingly , are typographic conventions and used to embolden text and italicize text for foreign & scientific words/phrases; , are to lend weight or importance to a word or phrase i.e 』em』 is not used simply to visually style text in italics
Links: External resource links: Provided to the bottom of the article framework is a section for links to external resources, please use this section for any links to resources that help further however please ensure that these links are additional resources and that your article does not depend on them for all or any part of your article explanation, the reasoning here is external links are not guaranteed to always be available and if the article relies on them and they are down then the article is effectively useless for users. Links that are not related directly to the article content are to be avoided and if found will be removed
Images: Do add images to articles where they help to illustrate your points or explanations, nothing helps illustrate things better than a timely graphic, screen shots of BuddyPress or WordPress screens help to show the reader layouts. As with links please avoid calling remote images, always upload to the media library, and embed. If uploading images please ensure you have the right to do so and are not infringing on any copyrights that may exist. Any images thought to be or that are under copyright will be removed from pages
Creating pages: When creating pages , please ensure you select a suitable 『Version』 tag, and optionally select from available 『Components』 tags & 『Types』. Please only select a parent category from the available parent sections, We request that authors DO NOT create new pages that act as parent pages for their article/s, this is to ensure the integrity of the codex structure, however it may be possible to expand the structure if thought beneficial, but please make a request for this to one of the Codex curation team members for consideration

Codex Conventions

Website Example Names: Always use example.com, example.org or example.net wherever you need to state a domain as an example. This is per RFC 2606.
Admin: The username admin describes the default administrator account of a WordPress installation in examples (admin should never be used on a live site due to negative security implications).
Using people』s names in examples: When a name is needed for an ordinary, non-admin user, or a person, use Harriet as the first name, and Smith as the last name
Administration Panels: The WordPress interface is called Administration Panels not admin panels or dashboard. Dashboard is a specific panel within Administration Panels. Individual panels are also called Administration Screens
WordPress is spelled WordPress: WordPress is spelled with two capital letters: WordPress
BuddyPress is spelled BuddyPress: BuddyPress is spelled with two capital letters: BuddyPress

With thanks to WP codex guidelines for borrowed bullet points: WP Codex:Guidelines
Formatting Guide
If writing a technical guide please use the template format provided in this draft document ( copy paste to new page ) Codex template – technical examples layout
1. Heading Tags:
Use h3 – h6. For example, on this page h3 is used for 「Sections」 above and for the title of this Section, 「Style and Formatting「.
2. Code examples: Surround your code with the appropriate shortcodes
[php] your PHP code [/php]
[html] your HTML code [/html]
Also available are bash, shell, css, diff, patch, js, javascript, plain, text, sql and xml and are used in the same format as the previous examples.
N.B: When adding code examples please escape angle brackets with Numeric/Decimal entities rather than 『Named ones, so use &# 060; and  &# 062;
3. Lists: Use unordered and ordered lists where appropriate.
4. File names: Surround file names with the code tags
index.php
5. The structure of a technical guide
[Intro]
a brief intro to the guide
[/Intro][Functions]
List the functions, location, params etc.
[/Functions][Your Content]
The content body – explanation/guide.
[/Your content][Example Usage]
Provide a simple example of code use – using pre/code tags.
[/Example Usage][Additional Resources]
Add any links to off site or internal pages that might help further.
[/Additional Resources]
Flagging articles – adding article header messages
Page may be tagged in the body with two 『Notes』
1/ This page is a legacy document (at top of page)
if a page is deemed to be outdated or superseded by BP versions, or changes then it may be marked with this code block

This is Legacy Document

The details in this page have either been updated or are deprecated completely. Legacy Docs are retained for historic reference.

and the page would be re-assigned under the parent section 『legacy』
2/ This page is in need of updating
A page is considered incomplete or needs to be verified for detail.

This page is incomplete or needs checking and verifying.

过滤器和常量参考

过滤器和常量参考

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

BuddyPress Core Filters and Constants
BudyPress provides a series of filters and constants you can add to your bp-custom.php or functions.php files to modify the behaviour of your BP install. These range from defining the avatar sizes BP will look for as defined defaults to filters that can be set to deactivate components fully such as @mentions
Constants

Define default values for BP avatars – shown are the BP default values; 『ORIGINAL_MAX_FILESIZE』 is a value generally taken from WP site settings.

?123456define( 'BP_AVATAR_THUMB_WIDTH', 50 );define( 'BP_AVATAR_THUMB_HEIGHT', 50 );define( 'BP_AVATAR_FULL_WIDTH', 150 );define( 'BP_AVATAR_FULL_HEIGHT', 150 );define( 'BP_AVATAR_ORIGINAL_MAX_WIDTH', 450 );define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000 );

Force BP to display usernames with spaces

?1define('BP_ENABLE_USERNAME_COMPATIBILITY_MODE', true);

Define the user account tab that is designated as the default to open with

?1define( 'BP_DEFAULT_COMPONENT', 'profile' )

Do the same as user account screens default page for Groups.

?1define( 'BP_GROUPS_DEFAULT_EXTENSION', 'members' );

Enabling this constant allows you remove the portion of the url path /members/ and have your member name at the 『Root『 of the domain url. N.B. If you use BP_ENABLE_ROOT_PROFILES there might be a situation where some user profiles get the same url as some posts or pages rendering either of them inaccessible. This might also be true of sub-sites if you』re running multisite with subdirectories. See ticket #1426 for more information.

?1define('BP_ENABLE_ROOT_PROFILES', true )

Allow User screens to be viewed under the domain path of MS sub domains / sub directories N.B. As of 1.7 it is recommended not to define this constant as BP will activate on individual sites.

?1define( 'BP_ENABLE_MULTIBLOG', true );

Enable private messaging to all users

By default you can only send private messages to people in your friends list, to change this behaviour you can add this constant to your wp-config.php or bp-custom.php file
?1define( 'BP_MESSAGES_AUTOCOMPLETE_ALL', true );

If you do allow this please consider that it allows possible spamming of you members , this is why if only friends can PM it』s by consent.

Filters
BP functions are well specified with filters available for most of them, these are a few that are provided to act as simple switches.

BP @-mention functionality is enabled by default If you don』t wish to use @-mentions, disable them completely.

?1add_filter( 'bp_activity_do_mentions', '__return_false' );

BP by default converts certain strings in user profiles to links, to disable this behaviour add:

?1remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );

Admin Bar: Since BP 1.6 the default behaviour has been to use the WP adminbar for BP related links deprecating the older BP buddybar

You may alter this behaviour and return to using the older style buddybar by adding this filter
?1add_filter('bp_use_wp_admin_bar', __return_false);

多站点的隔离 X-profile 字段

多站点的隔离 X-profile 字段

Codex Home → BuddyPress Theme Development → User Submitted Guides → Segregated X-Profile Fields for Multisite
Segregated X-Profile Fields for Multisite

Out of the box, all sites in a multisite install will share BuddyPress tables. That means that with a component like Extended Profiles, all sites will share the same profile fields, and changing them in one site will affect all others. However, with a few modifications you can create separate tables for each site, so Extended Profile Fields work independently on the network.
To do this, you need to modify the DB create queries for new sites, so when creating a new site, the tables for Extended Profiles will be automatically created. Once the tables are created, the $bp global entries for these table names will need to be modified, so at runtime the specific site』s newly created Extended Profile tables are accessed, not the shared ones.
This code will not create dummy content, so for every new site you will need to create a Profile Fields group and add profile fields to it manually. Add the following code to a functionality plugin network activated on your multisite install:

add_action('dbdelta_create_queries', 'add_custom_bp_xprofile_tables');

function add_custom_bp_xprofile_tables($sql) {
global $wpdb;
if ( ! empty($wpdb->charset) )
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
if ( ! empty($wpdb->collate) )
$charset_collate .= " COLLATE $wpdb->collate";

$sql[] = "CREATE TABLE {$wpdb->prefix}bp_xprofile_groups (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
name varchar(150) NOT NULL,
description mediumtext NOT NULL,
group_order bigint(20) NOT NULL DEFAULT '0',
can_delete tinyint(1) NOT NULL,
KEY can_delete (can_delete)
) {$charset_collate};";

$sql[] = "CREATE TABLE {$wpdb->prefix}bp_xprofile_fields (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
group_id bigint(20) unsigned NOT NULL,
parent_id bigint(20) unsigned NOT NULL,
type varchar(150) NOT NULL,
name varchar(150) NOT NULL,
description longtext NOT NULL,
is_required tinyint(1) NOT NULL DEFAULT '0',
is_default_option tinyint(1) NOT NULL DEFAULT '0',
field_order bigint(20) NOT NULL DEFAULT '0',
option_order bigint(20) NOT NULL DEFAULT '0',
order_by varchar(15) NOT NULL DEFAULT '',
can_delete tinyint(1) NOT NULL DEFAULT '1',
KEY group_id (group_id),
KEY parent_id (parent_id),
KEY field_order (field_order),
KEY can_delete (can_delete),
KEY is_required (is_required)
) {$charset_collate};";

$sql[] = "CREATE TABLE {$wpdb->prefix}bp_xprofile_data (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
field_id bigint(20) unsigned NOT NULL,
user_id bigint(20) unsigned NOT NULL,
value longtext NOT NULL,
last_updated datetime NOT NULL,
KEY field_id (field_id),
KEY user_id (user_id)
) {$charset_collate};";

$sql[] = "CREATE TABLE {$wpdb->prefix}bp_xprofile_meta (
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
object_id bigint(20) NOT NULL,
object_type varchar(150) NOT NULL,
meta_key varchar(255) DEFAULT NULL,
meta_value longtext DEFAULT NULL,
KEY object_id (object_id),
KEY meta_key (meta_key)
) {$charset_collate};";
return $sql;
}

add_action( 'bp_init', 'modify_bp_global_xprofiles_tablenames' );
add_action( 'switch_blog', 'modify_bp_global_xprofiles_tablenames' );

function modify_bp_global_xprofiles_tablenames() {
global $bp, $wpdb;
$bp->profile->table_name_data = $wpdb->prefix . 'bp_xprofile_data';
$bp->profile->table_name_groups = $wpdb->prefix . 'bp_xprofile_groups';
$bp->profile->table_name_fields = $wpdb->prefix . 'bp_xprofile_fields';
$bp->profile->table_name_meta = $wpdb->prefix . 'bp_xprofile_meta';
}