BuddyPress 提交访问

BuddyPress 提交访问

Codex Home → BuddyPress commit access
BuddyPress commit access

What is commit access?
The code that comprises BuddyPress is written by volunteers. Anyone who wants to suggest an improvement or a bugfix to the BP codebase is welcome to do so, by submitting their proposed changes to our Trac site.
The ability to add patches directly to BuddyPress is limited to those with commit access to the BP Subversion repository. Committers are individuals who have demonstrated, through ongoing contribution to the codebase and the BuddyPress community, a deep understanding of the codebase as well as the project ethos.
What is the role of a committer?
The primary duty of a committer is to assist community members with their code contributions to the project, through code review, technical consultation, and committing patches. When reviewing contributions, a number of different kinds of considerations should be weighed. First, the technical merits of a proposed change: performance, security, architectural and stylistic coherence with the rest of the codebase, etc. Just as important are the strategic and philosophical appropriateness of a contribution – whether it moves us closer to project goals, and so forth.
The BP project is proud of its collaborative nature. Most large architectural decisions in BuddyPress are made by rough consensus, and peer code review is an important part of the project culture. However, committers have the right to make final decisions about most issues: commit access means that you don』t need permission to make changes to BuddyPress. In cases where committers cannot come to consensus about technical decisions, the lead developers may serve as tiebreakers.
How are committers chosen?
Individuals may be nominated for guest commit access by any current committer. Nominations are reviewed by existing committers, with lead developers serving as the final decision makers. Guest committers may be offered permanent commit status at the discretion of the team.
Current committers
The following contributors have commit access to BuddyPress: John James Jacoby, Paul Gibbs, Boone Gorges, r-a-y, Mathieu Viet, mercime, Hugo Ashmore, David Cavins, Michael Beckwith, Slava Abakumov, Stephen Edgar and Laurens Offereins.

群组管理员 – 添加自定义列

群组管理员 – 添加自定义列

Codex Home → BuddyPress Plugin Development → Groups Admin – Add Custom Column
Groups Admin – Add Custom Column

It can be very handy to see additional information about each group when viewing the Groups screen in wp-admin.

The necessary hooks are found in this file: buddypress/bp-groups/classes/class-bp-groups-list-table.php

This example will add a column to show the number of pending member requests to join each private group. If a group is public there can be no pending requests, so we』ll show a simple dash in that row.

// add the column
function groups_admin_add_custom_column( $columns ) {

$columns["pending_group_members"] = "Join Requests";

return $columns;

}
add_filter( "bp_groups_list_table_get_columns", "groups_admin_add_custom_column" );

// add the column data for each row
function groups_admin_custom_column_content( $retval = "", $column_name, $item ) {

if ( "pending_group_members" !== $column_name ) {
return $retval;
}

if ( "private" == $item["status"] ) {

$user_ids = BP_Groups_Member::get_all_membership_request_user_ids( $item["id"] );

return count( $user_ids );
}

return "-";

}
add_filter( "bp_groups_admin_get_group_custom_column", "groups_admin_custom_column_content", 10, 3 );

This code can be placed in bp-custom.php .

BuddyPress 发布负责人和副手

BuddyPress 发布负责人和副手

Codex Home → BuddyPress Release Leads and Deputies
BuddyPress Release Leads and Deputies

The release lead works with all contributors to ensure the success of the release. The role blends aspects of being a product manager, project manager, engineering manager, release manager, and community manager. Release leads do not need to be developers, but having experience contributing to open source projects is required.
Release leads are supported by the lead developers, the project team, and deputies of their choosing. Volunteering as a release deputy is a great way to give it a try and learn about the process, but with a smaller time commitment.
For the sake of clarity, BuddyPress release leads and their deputies, between them, can expect to:

Run our weekly project meeting, and write and publish meeting notes on our development blog.
Coordinate blog posts and announcements on social media.
Make final decisions about whether a proposed feature is able to be put into the release.
Help new contributors make their contributions seen and heard in project meetings.

While BuddyPress is built by people volunteering their own time, contributing whatever they want, however they want, the release lead should take advantage of their position and use it to shape BuddyPress. For example, if the release lead feels that the next release should have a focus on specific aspects, we expect them to declare this, and try to encourage regular contributors to make that a reality.

添加电子邮件令牌

添加电子邮件令牌

Codex Home → Emails → Add Email Token
Add Email Token

Adding a token to an existing email can be done by using the bp_email_set_tokens filter.

For example, an email is sent when a member requests membership in a private group. Let』s add the requesting member』s email address to the body of that email.

function maybe_add_tokens_bp_email( $formatted_tokens, $tokens, $obj ) {

if ( isset( $formatted_tokens['requesting-user.name'] ) && isset( $formatted_tokens['requesting-user.id'] ) ) {

$user_info = get_userdata( $formatted_tokens['requesting-user.id'] );

$formatted_tokens['memberemail'] = $user_info->user_email;

}

return $formatted_tokens;

}
add_filter( 'bp_email_set_tokens', 'maybe_add_tokens_bp_email', 11, 3 );

This page lists the default tokens.

We can use that information to set the conditional so that the token is only added when a group membership request email is generated:

if ( isset( $formatted_tokens['requesting-user.name'] ) && isset( $formatted_tokens['requesting-user.id'] ) ) {
// etc

Now that we have added the memberemail token, we need to use the token in the body of the email.

Go to wp-admin > Emails and find the Membership request for group email. Roll over the name and click Edit. 

Then add the new token to the body of the email.

For example: Member Email: {{memberemail}}

Click Update and the token will be used every time that type of email is generated.

Twenty Seventeen 二〇一七主题

Twenty Seventeen 二〇一七主题

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

To change Twenty Seventeen』s default two-column layout to a full width layout as seen in the image above, add the following code to the `functions.php` file of your Twenty Seven child theme:
?12345678910// Remove the page-two-column CSS class from the body class in BuddyPress pagesfunction bp_remove_two_column_body_class($wp_classes) {    if( function_exists ( 'bp_loaded' ) && !bp_is_blog_page() ) :        foreach($wp_classes as $key => $value) {             if ($value == 'page-two-column') unset($wp_classes[$key]);        }    endif;    return $wp_classes;}add_filter('body_class', 'bp_remove_two_column_body_class', 20, 2);

过滤电子邮件

过滤电子邮件

Codex Home → Emails → Filter Emails
Filter Emails

You can filter the email fields by using the bp_email_set_tokens filter hook found in /bp-core/classes/class-bp-email.php.

For example, this will limit the BuddyPress message content to 50 words.Change 50 to whatever integer you want.

function bp_email_content_length( $formatted_tokens, $tokens, $obj ) {

$formatted_tokens['usermessage'] = wp_trim_words( $formatted_tokens['usermessage'], 50, '...' );

return $formatted_tokens;

}
add_filter( 'bp_email_set_tokens', 'bp_email_content_length', 10, 3 );

活动 → 好友

活动 → 好友

Codex Home → Member Guide → Activity → Friends
Activity → Friends

This panel shows all of your friends』 activities throughout the site.
Filter to Show:

Everything (default)
Updates
New Sites (if on Multisite installation)
Posts
Comments
Friendships (if Friendships are enabled)
New Groups (if Groups are enabled)
Group Memberships (if Groups are enabled)
Group Updates (if Groups are enabled)
Topics (if bbPress is activated)
Replies (if bbPress is activated)

⇒ Next: Activity → Groups
⇐ Previous: Activity → Favorites
⇐ Back to Member Guide

BuddyPress 封面图像

BuddyPress 封面图像

Codex Home → BuddyPress Theme Development → BuddyPress Cover Images
BuddyPress Cover Images

Note: This guide is for use with BuddyPress 2.4+. 
The Cover Images feature uses the BP Theme Compat API to maximize its compatibility with most WordPress themes. It allows members of your community, and groups administrators to upload an image to prettify their headers.

Themes using the BP Theme Compat API
A Group』s Cover Image in the TwentySixteen theme.
 
This is the most common case. The BP Theme Compat API is dynamically registering Cover Images for your members (if the the xProfile component is active) and/or your groups (if the Groups component is active) by:

Adding the feature to the features property of the component (buddypress()->profile->features and/or buddypress()->groups->features)
Adding the feature settings to the features property of the Theme Compat theme in use (BP Legacy in most cases: buddypress()->theme_compat->theme->features).

Although the BP Theme Compat API should make sure Cover Images are looking awesome within your theme, you may need to edit some of the feature』s settings to refine its appearance in your theme. To do so, you can use the following filters :

bp_before_members_cover_image_settings_parse_args for the members Cover Images
bp_before_groups_cover_image_settings_parse_args for the groups Cover Images

Here is an example to change the width and the height of the Cover Image for the members component:
function your_theme_xprofile_cover_image( $settings = array() ) {
$settings['width'] = 1170;
$settings['height'] = 250;

return $settings;
}
add_filter( 'bp_before_members_cover_image_settings_parse_args', 'your_theme_xprofile_cover_image', 10, 1 );

Here is an example to add a default image to use for Groups Cover Images:
function your_theme_xprofile_cover_image( $settings = array() ) {
$settings['default_cover'] = 'http://site.url/to/your/default_cover_image.jpg';

return $settings;
}
add_filter( 'bp_before_groups_cover_image_settings_parse_args', 'your_theme_xprofile_cover_image', 10, 1 );

You may also want to completely replace the default css styles BuddyPress is using for the Cover Image positioning. In this case using one (or both) of the above filters, you will define a new callback parameter and actually build this callback function so that it』s returning your css rules.
/**
* Your theme callback function
*
* @see bp_legacy_theme_cover_image() to discover the one used by BP Legacy
*/
function your_theme_cover_image_callback( $params = array() ) {
if ( empty( $params ) ) {
return;
}

return '
/* Cover image - Do not forget this part */
#buddypress #header-cover-image {
height: ' . $params["height"] . 'px;
background-image: url(' . $params['cover_image'] . ');
}
';
}

function your_theme_cover_image_css( $settings = array() ) {
$settings['callback'] = 'your_theme_cover_image_callback';

return $settings;
}
add_filter( 'bp_before_members_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 );
add_filter( 'bp_before_groups_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 );

About Template Part Overrides
The BP Theme Compat API allowes your theme to override the template parts BuddyPress is using to display its content as soon as you put your custom templates inside a subdirectory named 『buddypress』 or 『community』 in your theme』s directory.
If your theme is overridding the following templates:

buddypress/members/single/home.php
buddypress/members/single/profile.php
buddypress/groups/create.php
buddypress/groups/single/admin.php
buddypress/groups/single/home.php

Then you will need to upgrade these template parts according to the changes we have introduced about them since version 2.4.0. In this case, observe the corresponding template parts of the BuddyPress plugin (in the bp-templates/bp-legacy/buddypress directory) and apply the changes to your custom template parts.
About buddypress.css Overrides
The BP Theme Compat API also allowes your theme to override the BuddyPress stylesheet by putting a buddypress.css file into the css directory of your theme. If you』re doing so, you』ll need to edit your css file according to the css rules we』ve added in the 2.4.0 version. You』ll also need to filter the cover image settings so that the theme handle of your BuddyPress stylesheet is used instead of the BP Legacy one. There is also a great probability you』ll need to use a custom callback function. Here』s an example of the code you could use.
function your_theme_cover_image_css( $settings = array() ) {
/**
* If you are using a child theme, use bp-child-css
* as the theme handel
*/
$theme_handle = 'bp-parent-css';

$settings['theme_handle'] = $theme_handle;

/**
* Then you'll probably also need to use your own callback function
* @see the previous snippet
*/
$settings['callback'] = 'your_theme_cover_image_callback';

return $settings;
}
add_filter( 'bp_before_members_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 );
add_filter( 'bp_before_groups_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 );

 
Standalone BuddyPress Themes
A Member』s Cover Image in the BP Default theme
 
These themes are using their very own templates and are generally adding BuddyPress support (add_theme_support( 'buddypress' )) into their functions.php file. In this case, the BP Theme Compat API won』t register dynamically the BuddyPress Cover Images feature. These themes will need to register the feature in order to enjoy it. To show you how this can be achieved, let』s take the case of a well known Standalone BuddyPress theme: 「BP Default」.
First, you』ll need to make sure your Standalone BuddyPress Theme is following the recommendation of the WordPress Themes Handbook about how to include stylesheets for your theme using the wp_enqueue_style() function. BP Default is following this recommendation and uses 『bp-default-main』 as the stylesheet handle.
Then, you』ll need to register the Cover Images feature. You can choose to register it for Members and / or Groups by including (or not) the corresponding components in your feature』s settings.
// Register the Cover Image feature for Users profiles
function bp_default_register_feature() {
/**
* You can choose to register it for Members and / or Groups by including (or not)
* the corresponding components in your feature's settings. In this example, we
* chose to register it for both components.
*/
$components = array( 'groups', 'xprofile');

// Define the feature's settings
$cover_image_settings = array(
'name' => 'cover_image', // feature name
'settings' => array(
'components' => $components,
'width' => 940,
'height' => 225,
'callback' => 'bp_default_cover_image',
'theme_handle' => 'bp-default-main',
),
);

// Register the feature for your theme according to the defined settings.
bp_set_theme_compat_feature( bp_get_theme_compat_id(), $cover_image_settings );
}
add_action( 'bp_after_setup_theme', 'bp_default_register_feature' );

The different parameters of the Cover Image settings explained:

$components
An array to inform about the BuddyPress Components IDs you wish to activate the feature for.
eg: array( 'profile', 'groups' )
$width
An integer to set the width of the cover image.
$height
An integer to set the height of the cover image.
$callback
A string to define the callback function that will return your css rules for the cover image.
$theme_handle
The string used inside the wp_enqueue_style() function to identify the theme』s stylesheet.

Now the feature is registered, you will need to create the callback function used to include the css rules specific to the Cover Image feature. In this example, we called it bp_default_cover_image().
// Example of function to customize the display of the cover image
function bp_default_cover_image( $params = array() ) {
if ( empty( $params ) ) {
return;
}

// The complete css rules are available here: https://gist.github.com/imath/7e936507857db56fa8da#file-bp-default-patch-L34
return '
/* Cover image */
#header-cover-image {
display: block;
height: ' . $params["height"] . 'px;
background-image: url(' . $params['cover_image'] . ');
}
';
}

Finally, you』ll need to edit the following template parts according to the changes we have introduced in version 2.4.0:

members/single/home.php
members/single/profile.php
groups/create.php
groups/single/admin.php
groups/single/home.php

Additionally you can use your own templates for the Cover Image headers ones by creating the following into your theme:

members/single/cover-image-header.php
members/single/profile/change-cover-image.php
groups/single/cover-image-header.php

NB: if you are enqueueing your stylesheet by hooking 『wp_enqueue_scripts』 like it is recommended here and if the Cover Images specific css rules are not loaded, you may need to edit the priority of your hook to an earlier one like 9.
Neutralizing the Cover Images feature
As we have just seen, the feature is not automatically registered for Standalone BuddyPress themes, so this part should only concern themes using the BP Theme Compat API. If you need some time to 「fine-tune」 Cover Images for your theme, you can decide to completely deactivate the feature. In this case you can either use filters or stop the BP Theme Compat API from dynamically registering the feature.
Using Filters :
// For members :
add_filter( 'bp_is_members_cover_image_active', '__return_false' );

// For groups :
add_filter( 'bp_is_groups_cover_image_active', '__return_false' );

Stopping the BP Theme Compat API from dynamically registering the feature
function cover_images_no_support() {
remove_action( 'bp_after_setup_theme', 'bp_register_theme_compat_default_features', 10 );
}
add_action( 'after_setup_theme', 'cover_images_no_support' );

Finally, if the feature is registered, the community Administrators will always have the choice to deactivate the feature from the Settings > BuddyPress > Settings screen of their WordPress Administration.
BuddyPress Cover Images options

Related Resources

Using BuddyPress Cover Images inside the Member and Group Loops
Theme Compatibility
Overloading Template Compatibility theme files
WordPress Theme Handbook – Stylesheets

导航接口 API

导航接口 API

Codex Home → Developer Resources → Navigation API
Navigation API

BuddyPress』s Navigation API (BP 2.6+) provides an interface for developers to modify BP』s nav menus in group and user contexts.
Examples
Changing the position of the user』s Notifications nav item
function bpcodex_change_notifications_nav_position() {
buddypress()->members->nav->edit_nav( array(
'position' => 999,
), 'notifications' );
}
add_action( 'bp_setup_nav', 'bpcodex_change_notifications_nav_position', 100 );

Changing the name of the Unread subnav item of the user』s Notifications nav menu
function bpcodex_change_unread_nav_name() {
buddypress()->members->nav->edit_nav( array(
'name' => 'My Unread Notifications',
), 'unread', 'notifications' );
}
add_action( 'bp_setup_nav', 'bpcodex_change_unread_nav_name', 100 );

Listing all navigation items belonging to the current group
function bpcodex_get_current_group_nav_items() {
// Group nav items are technically subnavs of the top-level item with the current group's slug.
return buddypress()->groups->nav->get_secondary( array(
'parent_slug' => bp_get_current_group_slug(),
) );
}

Change item names of user』s and group』s nav menus
Profile menu
function bpcodex_rename_profile_tabs() {

buddypress()->members->nav->edit_nav( array( 'name' => __( 'My Buddy Forums', 'textdomain' ) ), 'forums' );
buddypress()->members->nav->edit_nav( array( 'name' => __( 'My Buddy Groups', 'textdomain' ) ), 'groups' );

}
add_action( 'bp_actions', 'bpcodex_rename_profile_tabs' );

Group menu
function bpcodex_rename_group_tabs() {

if ( ! bp_is_group() ) {
return;
}

buddypress()->groups->nav->edit_nav( array( 'name' => __( 'Group Discussion', 'buddypress' ) ), 'forum', bp_current_item() );
}
add_action( 'bp_actions', 'bpcodex_rename_group_tabs' );

Changing the position of group』s nav items
function bpcodex_group_tab_reorder() {

if( bp_is_group() ) {
buddypress()->groups->nav->edit_nav( array( 'position' => 1 ), 'forum', bp_current_item() );
buddypress()->groups->nav->edit_nav( array( 'position' => 2 ), 'send-invites', bp_current_item() );
buddypress()->groups->nav->edit_nav( array( 'position' => 4 ), 'home', bp_current_item() );
}
}
add_action( 'bp_actions', 'bpcodex_group_tab_reorder' );

Remove subnav tabs from Group Settings
function bpcodex_remove_group_manager_subnav_tabs() {
// site admin will see all tabs
if ( ! bp_is_group() || ! ( bp_is_current_action( 'admin' ) && bp_action_variable( 0 ) ) || is_super_admin() ) {
return;
}
// all subnav items are listed here.
// comment those you want to show
$hide_tabs = array(
// 'group-settings' => 1,
'delete-group' => 1,
'group-avatar' => 1,
// 'group-invites' => 1,
'manage-members' => 1,
// 'forum' => 1,
// 'group-cover-image' => 1
);

$parent_nav_slug = bp_get_current_group_slug() . '_manage';

//Remove the nav items
foreach ( array_keys( $hide_tabs ) as $tab ) {
bp_core_remove_subnav_item( $parent_nav_slug, $tab, 'groups' );
}
}
add_action( 'bp_actions', 'bpcodex_remove_group_manager_subnav_tabs' );

活动 → 小组

活动 → 小组

Codex Home → Member Guide → Activity → Groups
Activity → Groups

This page shows all the activities recorded in the groups you have joined.
Filter to Show:

Everything (default)
Updates
Group Updates
Group Memberships
New Groups
Topics (if bbPress is activated)
Replies (if bbPress is activated)

⇒ Next: Profile → View
⇐ Previous: Activity → Friends
⇐ Back to Member Guide