BuddyPress 2.8 需要 PHP 5.3+

BuddyPress 2.8 需要 PHP 5.3+

Codex Home → Getting Started → BuddyPress 2.8 requires PHP 5.3+
BuddyPress 2.8 requires PHP 5.3+

Starting with version 2.8, the minimum version of PHP required to run BuddyPress is 5.3.
Why the change?
PHP is the server-side programming language that powers WordPress and BuddyPress. Old versions of PHP are potentially unstable and insecure, and are missing some features that can be used to make BuddyPress faster and more powerful. The change is especially marked with the jump from PHP 5.2 to PHP 5.3, and the BuddyPress team has decided that now is the time to make the move.
Site administrators are strongly encouraged to run the latest stable version of all server software, including PHP.
See our PHP version compatibility guidelines for more details on how BP』s PHP version support is determined.
Am I affected?
Starting with version 2.7, BuddyPress creates a notice in the Dashboard if it detects that your installation doesn』t meet the minimum requirements for version 2.8+. If you reached this page via this kind of notice, then your server needs to be upgraded.
You can also check your PHP version using your hosting tools. For example, here is a tutorial from InMotion Hosting on using cPanel to view your PHP version.
How do I upgrade PHP?
Most popular webhosts have an interface for changing PHP version. Check your host』s documentation or support for more details. A few examples:

SiteGround
GoDaddy
Bluehost
DreamHost
HostGator

When in doubt, contact your host』s support.
What will happen if I don』t upgrade PHP?
BuddyPress 2.8 and later are completely incompatible with PHP 5.2: activating the plugin on an unsupported version of PHP will result in fatal errors.
BuddyPress 2.7 includes PHP version detection. If BP 2.7 detects that you are running PHP 5.2, it attempts to prevent you from upgrading to BP 2.8+ via all the normal WordPress upgrade paths (like Dashboard > Plugins). In this situation, your site will run BP 2.7.x until PHP has been upgraded.

贡献代码

贡献代码

Codex Home → Participate and Contribute → Contribute with Code
Contribute with Code

Thank you for your interest in contributing to BuddyPress! BuddyPress is an open-source project and, as such, is maintained by volunteers just like you. It is vital for the current, and future success of BuddyPress needs to have a healthy group of contributors. You are very welcome to join us to work on making the plugin as great as possible: every enhancement and each improvement depends on the community. This Quick Start Guide to contributing code to BuddyPress Core is where you can find the resources needed to take you through the process of submitting your first patch.

Choose the code editor you feel most comfortable with!

BuddyPress mainly uses four coding languages: PHP, JavaScript, CSS, and HTML. To write into these languages, you need a code/text editor. Here are below some suggestions for nice ones:

Visual Studio Code (download links),Sublime Text (download links),Atom (download links),Notepad++ (MS Windows only).If your a ninja, you can try Vim

Choose the version control system of your preference

BuddyPress uses a Subversion repository to manage the plugin』s code source. This repository is also mirrored on a Git repository. So the version control system you will use is up to you!

If you want to install Subversion, the WordPress 「Core Contributor Handbook」 has a great tutorial about it.

If you prefer Git and you』ve chosen a different text editor than Visual Studio Code (it is included into it), here are some ways to get it:

Git (download links),Git for Windows (download link)Command Line Tools for your Mac (They should be automatically downloaded if you type git or svn into a Terminal window).If you chose the Atom editor, you could install the Git/GitHub package,If you feel more comfortable with GUI software, you can use GitKraken or Sourcetree.

Install some additional tools to fully enjoy BuddyPress contribution

You probably won』t need all the tools listed below when you start contributing to BuddyPress. You can choose only to install NodeJS and install the other tools once you need them.

NodeJS latest LTS version (download links). Required.GruntJS (Installation procedure for the CLI) [1].Composer (Installation procedure) [2]. Once installed we advise you to make it globally available under the command name composer.WP CLI (Installation procedure) [3]. Once installed we advise you to make it globally available under the command name wp.PHPunit (WordPress installation tutorial, Alternative installation tutorial) [4] Once installed we advise you to make it globally available under the command name phpunit.

[1] GruntJS is used by BuddyPress to run some building tasks like preparing files to be committed, generating RTL versions of CSS stylesheets or minimizing JavaScript files.

[2] Composer is used to install some packages in order to be able to check PHP Code Compatibility and to run PHPUnit tests in our default local development environment.

[3] WP CLI is used to generate a POT file out of the plugin』s PHP and JavaScript files. This POT file is used by translators to translate BuddyPress into various languages (French, German, Spanish, etc..). For your information, WP CLI is a very powerful tool to run WordPress scripts from command lines.

[4] PHPUnit is used to run PHPUnit tests in any local development environment.

Get the BuddyPress development version

First you』ll need a Terminal software, macOs and Linux have been including such a software natively for years. If you』re using Microsoft Windows and chose to work with Git for Windows it includes a BASH emulation to run the same commands we』ll use into this tutorial, otherwise the latest Microsoft Terminal is looking great.

Once you opened a new Terminal window, create a new directory named 「buddypress」 into the local path of your choice.

mkdir ~/Plugins/buddypress

if you are using Subversion, run this command:

# SVN
svn co https://buddypress.svn.wordpress.org/trunk/ ~/Plugins/buddypress

If you are using Git, use this command instead.

# Git
git clone git://buddypress.git.wordpress.org/ ~/Plugins/buddypress

If you move to the ~/Plugins/buddypress directory once the download has finished, you should find the highlighted folders and files of the following screen capture.

Install our default local development environment

The BuddyPress development version you just downloaded contains the @wordpress/env package to generate a local environment using NodeJS (latest LTS version) and Docker. To install Docker, please follow the instructions listed below according to your operating system:

Windows 10 Pro,all other versions of Windows,macOS, Linux.

Once Docker is installed and is running in the background, open a Terminal window to setup your local development environment.

cd ~/Plugins/buddypress

From the ~/Plugins/buddypress the folder where you downloaded the code, you』ll first need to install the node modules we are using in BuddyPress. To do so simply run the following command and take a well-deserved break to let NodeJS download the modules we use as development dependencies (it might take some time!) :

npm install

For starters, if you face any error during npm install at the Microsoft windows env, you will also have to install windows-build-tools.

Once node modules are installed, if you plan to run/write PHP unit tests, you』ll also need to install some composer packages:

composer install

You should see that your ~/Plugins/buddypress directory now contains 1 or 2 more sub directories: /node_modules and /vendor if you installed the composer packages.

Now we can setup the local development environment using this command:

npm run wp-env start

The first time you』ll execute this command it will take some time to run and you』ll see that 2 downloads will start:

Core: it』s the WordPress development version.BP REST: it』s the plugin we use to develop the BP REST API.

Wait until the Terminal displays the following message:

✔︎ WordPress started. (in 00s 00ms)

Then, you can open your Internet Browser and go to this URL: http://localhost:8888/wp-admin/.

You』ll have a last step to achieve: setting the permalink structure to something else than the plain option. Here are the default credentials for the Administrator account:

Username: adminPassword: password

Other useful commands

Stopping the development environment

npm run wp-env stop

Once you run this command, you will quickly get the following confirmation message.

✔︎ Stopped WordPress. (in 00s 00ms)

Running PHP unit tests

If you chose to install Composer and the packages we use as development dependencies, you will be able to run our PHP unit tests suite (and of course contribute to it adding new tests).

On a regular WordPress configuration

npm run test-php

On a Multisite WordPress configuration

npm run test-php-multisite

Customizing your BuddyPress local development environment

To develop BuddyPress we use the development version of WordPress, the development version of the BP REST API and we set two debugging constants:

define( 'WP_DEBUG', true );
define( 'SCRIPT_DEBUG', true );

These options are defined into the .wp-env.json file of the BuddyPress repository. You can override these options using a file named .wp-env.override.json into your ~/Plugins/buddypress local directory.

For instance, you could choose to include another plugin like the one we use to develop BP Blocks using this content for the overriding file:

{
"core": "WordPress/WordPress#master",
"plugins": [ ".", "buddypress/BP-REST#master", "buddypress/bp-blocks#master" ],
"config": {
"WP_DEBUG": true,
"SCRIPT_DEBUG": true
}
}

Setting up a different development environment

Our goal with our local development environment is to try to make it easier & faster for new contributors to be ready to help the BuddyPress project. If you prefer to build your very own local environment: it』s totally fine! In this case, to contribute to BuddyPress, you』ll simply need to checkout our SVN repository or clone our Git mirror into the /wp-content/plugins directory of the WordPress you use into your local environment.

For your information, the WordPress core contributor handbook includes great tutorials to build such an environment.

Patching BuddyPress

Let』s work with a real bug example (It might has been fixed when you』ll read this page!) to understand how to suggest a fix to the BuddyPress development team. First, open the ~/Plugins/buddypress directory into your favorite code editor.

As you can see, I』m using the Visual Studio Code editor I like to have a tree of all directories and files on the left and a Terminal window under the opened file』s content.

The first big differences you will find with the way the BuddyPress plugin is organized into the WordPress Plugins directory are:

The plugin』s code is inside a src directory: that』s your main target as a new BuddyPress contributor.There』s a js directory at the same level than the plugin』s component directoriesThe plugin』s PHP unit tests suite is inside the tests directoryThere』s a bunch of configuration files like package.json or composer.json

Before doing any changes, I advise you to always synchronize your local copy of the BuddyPress development version with our central repository. Using your Terminal, simply run the command corresponding to the version control system you chose.

# SVN
svn up

# Git
git pull origin master

Once synchronized, let』s launch the BuddyPress local development environment.

npm run wp-env start

Once you get the confirmation it』s up and running, you can go to http://localhost:8888 to play with the WordPress site.

Finding an issue

If you log in and go to the Dashboard then open the BuddyPress』 tools submenu, here』s what you get.

Nothing special so far, but let』s activate one of the checkboxes, hit the 「Repair items」 button and have eyes on the notice that will then be displayed.

Then, you should see some lack of consistency with the WordPress administration general appearance:

The notice message does not used the width you could find in other administration screens.This notice message also has a bigger height, giving the impression the dismissible button (x) is not vertically aligned.

Moreover, it』s minor but, the color of the information above the 「Repair tools」 form (which seems to be an important advice) is lighter than the rest of the text.

If you look deeper using your Web browser software』s inspector and comparing the BuddyPress tools administration screen (image on the right) with another WordPress tools administration screen (image on the left), you』ll see HTML output [1] needs to be edited as well as the src/bp-core/admin/css/common.css file [2].

[1] You can see that compared to other administration screens, an hr tag is missing under the main title located into the h1 tag. Now if you compare the form structure with the one available into the WordPress Export tool, you can see it』s improvable. Let』s add an h2 tag to visually inform the users about what they need to do to select one or more tools and use the legend tag to inform screen readers about what to expect from the checkboxes. You can also wrap the checkboxes into a paragraph tag.

[2] If the notice message has a bigger height and a smaller width, it』s due to the BuddyPress Admin CSS file that is restricting the content』s width of the wrapper to 950 pixels max and is using a bigger line-height for paragraphs.

Editing the code to fix the issue into your BuddyPress local repository

The content of the BuddyPress tools administration screen is generated by the bp_core_admin_tools() function from the src/bp-core/admin/bp-core-admin-tools.php file.

To successfully warn the administrator about the potential database overhead that may happen if you run more than one tool at a time, you could use the attention CSS class instead of the description one that is used. You should also add the hr tag to delimit the end of the page』s header and use a form structure more inline with the WordPress Export tool 『s screen.

Once edits are saved, let』s check the results into the web browser. You need to reproduce the steps that made you discover the issue.

You still need to deal with the notice presentation: let』s edit the BuddyPress Admin CSS file!

As you』ve edited the HTML output, some CSS rules are not needed anymore and as you』ve seen earlier, you don』t need to restrict the width of the screen』s content wrapper. I believe you don』t need any of the CSS rules of the 5.0 Tools - BuddyPress section actually. So let』s remove it and update the sections numbering.

Generating the patch

To share your suggestion to fix an issue with the BuddyPress development team, you』ll need to use our Trac (our tool to manage the BuddyPress code source and track BuddyPress bugs).

If you don』t have a WordPress.org account yet, create one as you』ll need to log in the BP Trac to be able to submit tickets.

The patch is a file containing the code you changed compared with the existing code and you』ll use this file as an attachment to the Trac ticket explaining the issue.

Here』s the command to run to create this file:

# SVN
svn diff > ~/Desktop/replaceWithTicketNumber.diff

# Git
git diff --no-prefix > ~/Desktop/replaceWithTicketNumber.patch

NB: the --no-prefix option of the Git command is important so that people using SVN can apply your patch. If you want to avoid adding this option each time you create a patch, you can customize your Git configuration this way:

git config --global --bool diff.noprefix true

Here』s how the diff file should look like if you open it into your code editor:

Now you』ve created the patch, you need to clean things up so that next time you synchronize your local copy of the BuddyPress repository you don』t get errors. To do so, run the following command:

# SVN
svn revert -R *

# Git
git checkout .

Sharing your ticket on BuddyPress Trac

Now you have your patch ready and you cleaned your local copy of the BuddyPress repository, you can write a ticket about it to inform the BuddyPress development team about your great contribution. Head over to the BP Trac』s page to submit your ticket to do so.

Into the summary field, insert a short description of your issue. Use the Description multiline text field to detail your issue making sure to inform about the steps to reproduce it and eventually the specific configuration to use to reproduce it (eg: Multisite with BuddyPress active on a sub site). Don』t forget to add the has-patch keyword to your ticket and to activate the checkbox to attach a file once your ticket will be posted. You can include screenshots or any complementary information that can help understanding what your patch will fix once applied.

Submit your ticket and don』t forget to edit the name of your file to match the ticket number you』ll find once the next screen will load.

For this patch, the replaceWithTicketNumber.patch file should be renamed to 8357.patch.

Good job so far! You can have a look at the submitted ticket: #8357.

Every time your ticket will be updated (comments, commits, …), you』ll receive an email notification. Discussions about your ticket are likely to happen: eg. BuddyPress developers may ask you to update/edit your patch. You』ll see these discussions can be really interesting and can greatly help you improve your skills.

Applying a patch to your local copy of the BuddyPress repository

There are 2 situations when you』ll need to apply a patch to your local copy of the BuddyPress repository:

You need to update a patch you previously shared on BP Trac.You want to contribute to a patch shared by another contributor and provide him with your feedbacks about it.

In both cases, the commands to run are the same. First from your Terminal software move to your BuddyPress repository』s local copy.

cd ~/Plugins/buddypress

Once there, don』t forget to synchronize your local copy with the central BuddyPress repository.

# SVN
svn up

# Git
git pull origin master

If you installed the GruntJS tool, you simply need to run this command:

grunt patch:8357

8357 is the ticket number (the one that was created in previous chapter).

Otherwise, you』ll need to download the patch from the ticket』s page before applying it.

Once downloaded, whether you use SVN or Git the command to apply the patch is the same.

patch -p0 < /path-to-the-downloaded-patch/8357.patch

Once you finished updating your patch (& possibly generating a new version of it) or testing another contributor』s patch, don』t forget to clean your BuddyPress repository』s local copy.

# SVN
svn revert -R *

# Git
git checkout .

Follow WordPress Coding & Documentation standards

When editing the BuddyPress code source, it』s important your code follows the WordPress Coding Standards. I advise you to check them often as they can be updated. Here are the coding standard links:

AccessibilityCSSHTMLJavaScriptPHP

For the inline documentation (for Classes, hooks and functions DocBlocks) you might use into your code, it』s also important to use these WordPress standards:

JavaScriptPHP

Congratulations! You are now ready to contribute to the BuddyPress code source. If you』re looking for issues to fix, check our roadmap and click on the 「active」 link of the latest milestone to discover what we need to do

「Nouveau」 群组邀请用户界面

「Nouveau」 群组邀请用户界面

Codex Home → Getting Started → User Submitted Guides → A 「Nouveau」 Group Invites User Interface
A 「Nouveau」 Group Invites User Interface

「Nouveau」 is the name of the new Template Pack bundled within the 3.0.0 release of BuddyPress. You can activate it from the BuddyPress Options Administration screen. 「Nouveau」 comes with some new Backbone.JS based User Interfaces and one of them, the Group Invites UI, is experimenting an alternative way to deal with single group invites. In short: it』s always possible to invite community members when 「Nouveau」 is the selected Template Pack!
Selecting Members to invite.

The Group Invites UI uses a dynamic tabbed interface to help you choose the members you want to invite into your existing or your new group. If the Friends component is active, you』ll find 2 tabs 「My Friends」 and 「All Members」 to perform this selection. Otherwise you will always find at least the 「All Members」 tab.

To add a new member to your group invites, you need to click on the 「+」 icon. Once done, a new tab named 「Send Invites」 is dynamically added under the others. It contains a counter to inform you about the number of members you added to your invites list.

If you added a member by mistake, you can remove him from the list clicking on the 「x」 icon.

You can switch between tabs at anytime to select the members or friends you need to invite into your group, you won』t lose the members you already selected.

If your community is large, you can use the search field to filter the displayed members.

When your selection is ready, click on the 「Send Invites」 tab to send your invites to the selected members. If you realize at this point you don』t want to invite 「Laurent」, just click on his avatar to remove him from your invites list. If you want to explain why the invited members should join your group, you can add a message to your invite. Oh and don』t forget to click on the 「Send」 button to actually send the invites !!
Checking for pending invites.

When a group has pending invites you can check it to see if one of your friends is already invited. Oh by the way, if you don』t find a specific member into the 「My Friends」 or 「All Members」 tab, there』s a good chance you』ll find him into these pending invites or into the existing Group Members
Putting all screens together

Video Playerhttps://cldup.com/ubTOhLK6EX.mp400:0000:0000:00Use Up/Down Arrow keys to increase or decrease volume.
 
Restricting the user listed into the 「All Members」 tab
Any member can choose to disappear from the 「All Members」 tab at anytime from their 「Group Invites」 settings profile page.

If you are the site owner, you can also completely disable the 「All Members」 tab by using the following code into your bp-custom.php file :
add_filter( 'bp_nouveau_groups_disallow_all_members_invites', '__return_true' );

模板更新 2.7

模板更新 2.7

Codex Home → BuddyPress Theme Development → Updating Custom Themes For New Functionality → Template Updates 2.7
Template Updates 2.7

In BuddyPress 2.7 we introduce some new features that specifically require template adjustment.
These changes are of importance for theme developers who may have overloaded the templates to the themes directory and these will need to be updated from the details here. If you are simply inheriting templates then there is no need to worry. Do note however some updates are not critical but are enhancements theme developers might like to carry through to their templates.
Changes for this release are:

Directory search form include part
Groups admin manage screens
Search form for groups manage members screens
Improve group manage members screen.
Group Type front-end integration
Templates heading element changes

Directory Search Form (Trac #6844)
We introduced a new folder for themes to hold common shared parts; in this we have added a revised copy of the directories search form that is included into all main directory component screens.
This is not a breaking change; if you choose not to update templates the search elements will function normally.
Files needing updating are:

buddypress/activity/index.php
buddypress/members/index.php
buddypress/groups/index.php
buddypress/blogs/index.php

If you need to make changes to the shared search form, create a new folder in your /buddypress/ or /community/ directories named common/search/ and copy in the new file from bp-legacy then modify.
In all of the above files, locate the search form block and replace with

Groups Admin Manage Screens (Trac #7079 )
groups/single/admin.php is now broken out by admin screen for ease of editing and overriding indivdual screens.
Although no changes are required, as there is no appreciable change other than convenience for developers, you might like to examine groups/single/admin.php & single/admin/ to see the changes and perhaps copy over.

Search Form for Groups Manage Members Screens (Trac #6385)
Adds search capability to the admin manage members screen.

groups/single/admin.php

If you』ve added the new bp_before_group_admin_form action to groups/single/admin.php, and have not overridden bp-legacy/buddypress-functions.php, then a search form will be added above the manage members list. If you have overridden bp-legacy/buddypress-functions.php, see the changeset for implementation details.

Groups Manage Members Lists (Trac #7105)
This update improves the structure of list items to more closely match members-loop.php.
Although this isn』t a breaking change you may like to update any overloaded templates for this improvement.

groups/single/admin/manage-members.php

Replace the blocks beginning

and ending before the final endif before start of new bp-widget div block with the one below in respective order:
Admins loop

15, 'group_role' => array( 'admin' ), 'page_arg' => 'mlpage-admin' ) ) ) : ?>

  • 1 ) : ?>
    <a class="button confirm admin-demote-to-member" href="">

Mods loop

15, 'group_role' => array( 'mod' ), 'page_arg' => 'mlpage-mod' ) ) ) : ?>

  • <a href="" class="button confirm mod-promote-to-admin">
    <a class="button confirm mod-demote-to-member" href="">

General members loop

15, 'exclude_banned' => 0 ) ) ) : ?>

    <li class="">

    <?php
    if ( bp_get_group_member_is_banned() ) {
    echo ' ';
    _e( '(banned)', 'buddypress' );
    echo '
    ';
    } ?>

    <a href="" class="button confirm member-unban" title="">

    <a href="" class="button confirm member-ban">
    <a href="" class="button confirm member-promote-to-mod">
    <a href="" class="button confirm member-promote-to-admin">

    <a href="" class="button confirm">

Group Type Front-End Integration ( Trac #7210 )
This feature updated and extended the work done on establishing a group type taxonomy in 2.6; it provides for front-end integration of type selection and management in the group creation steps & the manage settings screens.
In this release two new template tags are added that display all group types on a groups loop display & the current group type(s) on a single group screen. The following templates need updating:

groups/create.php
groups/groups-loop.php
groups/single/admin.php
groups/cover-image-header.php
groups/group-header.php

create.php: in the create step 2 screen we display a list of group types to select from. The markup below needs to be copied after the privacy options block and before the group invitations on screen 2 although you can move this where you need it.

true ), 'objects' ) ): ?>

<label for="name ); ?>"><input type="checkbox" name="group-types[]" id="name ); ?>" value="name ); ?>" /> labels['name'] ); ?>
description ) ) {
/* translators: Group type description shown when creating a group. */
printf( __( '– %s', 'buddypress' ), '' . esc_html( $type->description ) . '' );
}
?>

groups-loop.php: In the groups-loop template we have a template tag to display a group directory message. This block would be copied to a position just before the bp_has_group() query:

admin.php / group-settings.php: In 2.7 we split the admin manage file into separate includes so the block below is either copied just before the group-create-invitation fieldset or simply copy over the newer template parts to your theme.

true ), 'objects' ) ): ?>

<label for="name ); ?>">
<input type="checkbox" name="group-types[]" id="name ); ?>" value="name ); ?>" name ) ); ?>/> labels['name'] ); ?>
description ) ) {
printf( __( '– %s', 'buddypress' ), '' . esc_html( $type->description ) . '' );
}
?>

cover-image-header.php & group-header.php: both these header files get a new template tag for displaying the group type for that group. Copy the tag below to the #item-header-content div or position of your choice.

Template Heading Element Changes
In 2.7 we have adjusted many of the heading elements used to effect a better and proper document outline structure and improved accessibility.
This is more an advisory notice as the styling of these element has been adjusted in the default BP stylesheets to minimize the visual change.
There may be cases where themes have overloaded BP stylesheets but not templates in which case those developers may want to check through the various headings for any necessary styling updates required, e.g. font-size changes.

替代注册工作流程

替代注册工作流程

Codex Home → Administrator Guide → Alternative Registration Workflows
Alternative Registration Workflows

By default, registration in BuddyPress follows this workflow:

A site administrator can enable registration by checking 「Anyone can register」 on the WP Admin > Settings > General options screen.

If registration is enabled, then site visitors can sign up for an account using the registration form.

Once the registration form has been submitted, the user will be sent an activation email that verifies that the user』s email address is legitimate.

Once the user activates her account, she will be able to login using the username and password she specified on the registration form.

Changing the Registration Process

You can change the default BP registration flow by allowing member invitations and/or requiring membership requests. These features can be used separately or together to change who is allowed to join your site.

Invitations

Invitations can be used when public registration is open to help grow your site』s membership or when public registration is closed to only allow membership by referral from an existing member.

Enable membership invitations by visiting the WP Admin > Settings > BuddyPress > Options screen.

Your site members can send invitations from their user profiles.

The invited member will receive an email containing a link to the registration form.

Even if you have disabled public registration, valid invitation holders will be able to access the form using the link in the email.

Once the user registers, the account will be activated immediately (responding to the invitation has already verified the user』s email address) and will be able to log in to the site.

Membership Requests (available in BuddyPress 10)

Enabling membership requests interrupts the registration process by preventing the activation email from being sent automatically, and instead requires that a site administrator manually review and approve each account request.

Enable membership requests by visiting the WP Admin > Settings > BuddyPress > Options screen. Note that public registration must be disabled for requests to be activated.

Then, visitors will be able to visit the registration form to submit a membership request.

When a new request is submitted, the site admins will receive a site notifications and an email. The email can be disabled via the user』s email preferences screen.

The email message that a BuddyPress site admin receives when a new request is submitted.

The link in the email or site notification will take the administrator to an approval screen where she can review the submitted membership request and choose to confirm it.

The administrator can also visit the Manage Pending Memberships screen at WP Admin > Users > Manage Pending Memberships.

Hovering over a row will reveal the following actions available to the admin:

「Activate」 will activate the user immediately without requiring that they validate their email.「Approve Request」 or 「Resend Approval」 takes you to the confirmation screen before being able to send the activation link to the desired pending request. You can only send the activation email once per day.「Profile Info」 will display extended profile information for the request.「Delete」 allows you to delete a pending account from your site. You will be asked to confirm this deletion.

If the administrator approves the request, the submitter will receive an activation email and can complete their registration.

If the administrator deletes the request, the submitter will receive an email telling them that their request has been declined.

Membership Requests – Automatically approving some membership requests.

There are cases where every user that satisfies some criteria should be granted access immediately and not require manual approval. For example, if you are building a site for students and staff at a specific school, you might want to approve every request that comes in from any user with a my-school.edu email address. You can do this by adding a filter like the following to your bp-custom.php file or your theme』s functions.php file:

?123456789101112131415161718192021222324252627<?php /** * If a user submits a site membership request, but has a * 'my-school.edu' email address, bypass the manual approval of the request. * * @param bool  $send    Whether or not this membership request should be approved *                       immediately and the activation email sent. *                       Default is `false` meaning that the request should be *                       manually approved by a site admin. * @param array $details The details of the request. */function bpcodex_auto_approve_some_requests( $send, $details ) {    // We'll need the prospective user's email address.    if ( empty( $details['user_email'] ) ) {        return $send;    }     $email_parts = explode( '@', $details['user_email'] );     // If the email address is one of ours, approve the request.    if ( ! empty( $email_parts[1] ) && 'my-school.edu' === $email_parts[1] ) {        $send = true;    }     return $send;}add_filter( 'bp_members_membership_requests_bypass_manual_approval', 'bpcodex_auto_approve_some_requests', 10, 2 );

?1

群组类型

群组类型

Codex Home → Developer Resources → Group Types
Group Types

BuddyPress 2.6 introduced the concept of group types. This functionality is outlined below.
Registering group types
BuddyPress itself does not register any group types. Plugins and themes can register group types using the bp_groups_register_group_type() function:
function my_bp_custom_group_types() {
bp_groups_register_group_type( 'team', array(
'labels' => array(
'name' => 'Teams',
'singular_name' => 'Team'
),

// New parameters as of BP 2.7.
'has_directory' => 'teams',
'show_in_create_screen' => true,
'show_in_list' => true,
'description' => 'Teams are good',
'create_screen_checked' => true
) );
}
add_action( 'bp_groups_register_group_types', 'my_bp_custom_group_types' );

The first parameter of bp_groups_register_group_type() is a string identifier for the group type, used internally by BP as the canonical name of the type. This name should be unique. The second parameter is a list of generic config arguments (see Configuration Arguments section for full details).
Registering a group type will also enable a meta box so administrators can set a groups』s type when editing a group in the WP admin dashboard.
Configuration Arguments

'labels' (available as of BP 2.6)
An array consisting of the 'name' and 'singular_name' keys. 'name' is for the plural form of the group type.

'has_directory' (available as of BP 2.7)
If this argument is passed (eg. 『ninja』), a list of members matching the group type will be available as a filter from the Groups Directory page. (eg. http://example.com/groups/type/ninja/. You can pass any string to customize the URL for the group type』s directory.) Default: false.

'show_in_create_screen' (available as of BP 2.7)
If set to true, the group type will be selectable during group creation and when a group administrator is on the group』s 「Manage > Settings」 page. Default: false.

'show_in_list' (available as of BP 2.7)
If set to true, the group type will be shown when the bp_group_type_list() function is used by default. Currently, the group type list is shown when on a group page. This defaults to true if 'show_in_create_screen' is set to true. Default: null.

'description' (available as of BP 2.7)
Used to describe the group type. If this is passed, this is currently shown on the group creation screen to describe the group type.

'create_screen_checked' (available as of BP 2.7)
If the 'show_in_create_screen' argument is set to true, this argument will toggle the checkbox for our group type so it is checked by default during the group creation process. This is handy if you wanted to imply that the group type should be enforced, but the decision ultimately lies with the group creator. Default: false.

Querying by group type
A common task is to retrieve a list of groups of a given type (or set of types). bp_has_groups() and BP_Groups_Group::get() accept a 'group_type' parameter, which can be a single group type or an array/comma-separated list of group types. This will filter query results to those groups matching the type. Example:
// Fetch all teams and companies.
$group_args = array(
'group_type' => array( 'team', 'company' ),
);
if ( bp_has_groups( $group_args ) ) { // ...

Fetching and setting group types
When BuddyPress detects that group types have been registered, it will display a Group Type metabox when editing a group』s page in Dashboard > Groups. Administrators can use this interface to view or change a groups』s type.
BuddyPress also provides simple functions for fetching and setting group types programatically. To get the group type of a group, use bp_groups_get_group_type():
// Get the group type of group 5412.
$group_type = bp_groups_get_group_type( 5412 );

Set a group』s type using bp_groups_set_group_type():
// Set the group type of group 5412 to 'team'.
$group_type = bp_groups_set_group_type( 5412, 'team' );

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

注册 (Registration)

注册 (Registration)

Codex Home → Member Guide → Registration
Registration

1. Click on the 「Register」 link. Some sites use 「Join Us」, 「Sign Up」, or other terminology.

2. Fill in the forms. Some sites allow you to create your own blog. You can fill up the form to create one now, or choose to create a new blog later.
3. Click on the 「Complete Sign Up」 button.
4. Check Your Email To Activate Your Account! You have successfully created your account. To begin using this site you will need to activate your account via the email we have just sent to your address.
5. Wait for a minute or so if you don』t see the email to activate your account. If the activation email doesn』t show up in your inbox, check your 「Spam」 folder just in case it was redirected by your email client.
6. Click on the activation link in the email. This will bring you to the homepage of the site.
7. Fill up the rest of your profile information if you only completed the 「required」 fields during registration. Or, begin exploring the Sitewide Activity, Groups you can join, or other Members you can befriend, and many more.

⇐ Back to Member Guide

活动嵌入

活动嵌入

Codex Home → Activity Embeds
Activity Embeds

Intro
WordPress added oEmbed provider support in v4.4.0, allowing users to easily embed posts by copying a WordPress post URL and pasting it into the WordPress editor.
WordPress 4.5.0 made further enhancements to the embed template for easier customization for theme developers.
In BuddyPress 2.6.0, we are piggybacking off this functionality and enabling oEmbed provider support for single activity item.
This means you will be able to embed single activity items by copying the activity permalink and pasting it into the WordPress editors.
For example:
Your WordPress version is 4.5 or higher, you can enjoy the Activity Embeds feature we』re introducing in BuddyPress 2.6!https://videopress.com/v/VwVrGm7a?hd=1– Paul Gibbs (@djpaul) June 15, 2016

This feature will require WordPress 4.5+.
Disabling Activity Embeds
If you do not want your BuddyPress site to have activity embeds enabled, you can disable the feature with this small code snippet:
add_filter( 'bp_is_activity_embeds_active', '__return_false' );
Media in Activity Embeds
If an activity item includes a URL from a registered WordPress oEmbed provider on its own line:
https://codex.wordpress.org/Embeds#Okay.2C_So_What_Sites_Can_I_Embed_From.3F
We will attempt to display an image and caption of that oEmbed item in the activity embed template.
If a URL from a registered WordPress oEmbed provider isn』t found, we will attempt to embed an inline audio or video URL using your browser』s native HTML5 player.
Information for Theme Developers
As a theme developer, if you do not like the default look of activity embeds, you can override any of the template parts located at /wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/assets/embeds/ by copying them to your theme』s directory.
Let』s say I want to make some tweaks to the activity header embed template part, copy /wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/assets/embeds/header-activity.php to /wp-content/themes/YOUR-THEME/buddypress/assets/embeds/header-activity.php and make your changes.
If you want to override the CSS, copy /wp-content/plugins/buddypress/bp-templates/bp-legacy/css/embeds-activity.min.css to /wp-content/themes/YOUR-THEME/buddypress/css/embeds-activity.min.css or /wp-content/themes/YOUR-THEME/css/embeds-activity.min.css and make your changes.
If you have WP_DEBUG turned on, then omit the '.min' suffix.
Note: CSS is rendered inline in the tag. This is similar to what WordPress is doing in their embed template.
Information for Template Pack developers
If you do not know what a template pack is, you do not need to read this section!
As of BuddyPress 2.6, if you are developing a custom template pack that is not bp-legacy, for activity embeds to display properly, you will need to copy the following to your template pack』s directory:

/wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/assets/embeds/
/wp-content/plugins/buddypress/bp-templates/bp-legacy/css/embeds-activity.css
/wp-content/plugins/buddypress/bp-templates/bp-legacy/css/embeds-activity-rtl.css
/wp-content/plugins/buddypress/bp-templates/bp-legacy/css/embeds-activity.min.css
/wp-content/plugins/buddypress/bp-templates/bp-legacy/css/embeds-activity-rtl.min.css

There is a proposal to eliminate this copying process in future versions. Keep an eye on the following ticket for more info:
https://buddypress.trac.wordpress.org/ticket/7116
Information for Plugin Developers
In order for oEmbed to work with BuddyPress activity items, we register a custom endpoint with the WordPress oEmbed REST API:
example.com/wp-json/oembed/1.0/embed/activity?url=URL_TO_ACTIVITY_ITEM
As well as supporting the regular oEmbed parameters like url, format and maxwidth:
http://oembed.com/#section2.2
The BP Activity oEmbed endpoint also supports the hide_media parameter.
If this is set during the oEmbed request, no media items will be displayed in the embed.