BP 1.7 – 升级 「模板打包」 主题

BP 1.7 – 升级 「模板打包」 主题

Codex Home → Legacy Docs → Archived Section: Theme Development → BP 1.7 – Upgrading 「Template Packed」 Themes
BP 1.7 – Upgrading 「Template Packed」 Themes

Archived file. Good up to BP 1.8.

From BuddyPress 1.2 through 1.6.5, most WordPress themes went through the BP Compatibility process via the BuddyPress Template Pack plugin to align the HTML structure of the BP template files with that of the respective WP theme.
BuddyPress 1.7 is now compatible with nearly all WordPress themes available in the market. To make your BP component pages future-proof, it』s time to take advantage of the theme compatibility BP 1.7 brings to the table. Activated BP components will automagically be inserted into your theme』s default page structure.
Upgrading to BP 1.7 – Changing from BP Template Pack to default BP 1.7 Theme Compatibility

Back up or download a copy of your WP theme folder in server which contains the template-packed files or folders.
Deactivate the BP Template Pack plugin in Plugins > Installed.
Delete the six (6) BP folders transferred to your theme』s folder in server when you went through the BP Compatibility Process: /activity, /blogs, /forums, /groups, /members, and /registration. If you have a header-buddypress.php, sidebar-buddypress.php and/or a footer-buddypress.php files, delete those files as well via s/FTP or control panel.
Upgrade to BuddyPress 1.7.
Check out your site』s BP pages – activity, members, etc. – which should contain the respective BP components activated in Settings > BuddyPress.

Frequently Asked Questions
BP 1.7 Theme Compatibility is not working on my theme.
That could be due to a variety of reasons including the WordPress theme』s customized templating, erroneous coding, missing page titles in pages and so forth, all of which are beyond our control. Please create a topic at the BuddyPress Forums and report the problem.
To facilitate troubleshooting, open up your theme』s page.php file, copy all code, paste into pastebin.com and post the generated URL in your support topic. While troubleshooting is going on, re-upload the theme folder you backed up in #1 above which contains the template-packed files/folders to wp-content/themes/ and activate BP Template Pack plugin.
I want to remove the sidebar and have full-width layout for all BuddyPress pages.
1. Open the full-width template in your theme with a text editor and copy all source code.
2. Create a file named buddypress.php and paste the copied source code into the file and save.
3. Upload buddypress.php to your theme』s folder in server i.e., wp-content/themes/yourtheme/
reference: A Brief overview of BuddyPress Theme Compatibility in 1.7
Note: Customize the layouts of BuddyPress pages within the WordPress Default Themes
Why do my sitewide and group forums still have a sidebar even when I uploaded a full-width layout with buddypress.php file?
That』s because since BP version 1.7, sitewide and group forums are rendered by the bbPress plugin. You』d need to copy the full-width template source code into a new file named bbpress.php

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

主题兼容性和模板文件

主题兼容性和模板文件

Codex Home → BuddyPress Theme Development → Theme Compatibility → Theme Compatibility & Template Files
Theme Compatibility & Template Files

An explanation of Theme compatibility and its template files
BuddyPress 1.7 heralded a new era in BP development with a vastly improved approach to templating, its aim being to far more closely mirror the WordPress core templating loading approach.
BuddyPress theme compatibility is based on the great work done by John James Jacoby with the standalone bbPress plugin and ported over to BuddyPress.
What this enhancement means in real terms is that now BuddyPress has the ability to provide its core template files injected into standard WordPress templates in a seamless manner. In other words, users may now choose any WordPress theme for their site and then simply activate the BuddyPress plugin. BuddyPress will automatically check to see if the default BP theme is activated; if not, it will fall back to using the new template files for theme compatibility and select a template file from the parent in the same manner WP does in a template hierarchical fashion
E.G., if your theme has a page.php file, BP will use that file to generate the BuddyPress content
To try and ensure that BP content fits in with a chosen theme as much as is possible, only a very basic set of styles are provided.
When working in theme compatibility mode, BP will look for a series of templates in a specific order much in the same manner WordPress does with it』s main templates ( to better understand template hierarchy read the WP codex page: https://codex.wordpress.org/Template_Hierarchy )
The order of precedence for the file BP will use is:

『plugin-buddypress.php』
『buddypress.php』
『community.php』
『generic.php』
『page.php』
『single.php』
『singular.php』
『index.php』

What this means is BP will look for each named file in the order shown in the stylesheet_directory first (a child theme folder) then in the template_directory (parent theme folder)
As soon as it finds one then that file is used and BP generates its content via this file using the files structure(markup) & get_*( ) calls ( technically BP bypasses the content loop replacing it with the BP content ).
How is this useful?
Use a custom template file for all BP content
This ability to describe what file to use means the user/author may ensure a unique file for BP is used while not having to modify the standard WordPress file e.g. page.php
So if we want to remove the sidebar for BP pages but not for all WP 『pages』 or call a specific BP sidebar get_sidebar(『buddypress』), we could take a copy of page.php and rename it to 『community.php.』 (or 『buddypress.php』) and have BP use this file for all it』s requirements, as can be seen from the order above the first two files will not be found but the third will be and therefore used.
Overloading Template Compatibility theme files
Template compatibility also runs a check to see if two directories or folders exist in a theme:

『buddypress』
『community』

If either of these two folders exist in your theme and they contain BP template files then those files will be used in preference to the bp plugins versions.
Therefore, you can modify any bp theme compatibility template by copying it over from:
/bp-templates/bp-legacy/buddypress/
To:
/my-theme/community/ or /my-theme/buddypress/
N.B. Inside the subfolder 『community』 you must preserve the path structure/folders that exist in the BP original /buddypress/ folder so /activity/ must be created to hold index.php or any of the other activity templates.
Additionally to keep things neat & tidy you can keep your custom parent template file 『community.php』 in these folders as well rather than your theme root.
You may override the css by adding a folder /css/* to your theme root if you then, either, copy buddypress.css from /bp-legacy/ or create a new file named buddypress.css this file will be used instead of the buddypress version.
* As of BP 1.8 the paths for assets i.e styles and JS has been modified to look to your 『buddypress』 or 『community』 folders first, this means you will be able to locate your /css/ folder inside your buddypress one.
Child Themes
As mentioned earlier, BP will search the stylesheet and template paths for BP files/folders. This means that the principle of creating child themes still holds true and is to be a strongly recommended procedure to follow as always.
As a brief example, if you』re creating a theme using TwentyTwelve as a base, instead of dropping custom files into the parent theme you would create 2012-child with a stylesheet style.css that has a header line:
Template: TwentyTwelve
In your child theme you would then have all your custom BP templates this way updating WP will not overwrite any changes you have made.
For information on creating child themes see: https://codex.wordpress.org/Child_Themes
This has been a basic guide to familiarise you with the new template files and how you can make them work for you in your chosen theme and more advanced options exist.
As of BP 1.8 we introduce an enhanced template hierarchy, this new addition allows the developer to specify unique templates for BP screens such as 『Groups』, 『User』 now we can create templates that take a suffix such as a user id, or an 『Action』 or 『Component』; these templates then cut in and provide a custom view in the same manner the template hierarchy does presently in 1.7. You can read a more detailed breakdown and explanation of this new template hierarchy on this page: Enhanced template-hierarchy in BP 1.8

More on BuddyPress 1.7 Theme Compatibility

信息 (Messages)

信息 (Messages)

Codex Home → Administrator Guide → Messages
Messages

Sections

Public Messages
Private Messages

Private Message Screens
How to Send a Private Message

Public Messages
BuddyPress provides ways for you to send a message publicly to another member of the site or network. Members will be notified of public messages by a new message count in the Notifications circle in Admin/Toolbar as well as receive an email notifications, if enabled by said member.

Mention the member by using the 「at sign」 ( @ ) + member username, e.g. @mercime. Mentioning the user can be done anywhere within the BuddyPress site:

Status Update form in the Sitewide Activity page, Group Activity page or in your own profile page
Activity Stream Comment and/or Reply form
Forum Topic Post or Reply Post – if the bbPress forums (sitewide or group) plugin is activated in your site

Click on the Public Message button located beside the member』s avatar in his/her profile page (see image above). That brings you to your own Activity Status Update form with that member』s username already mentioned. Add your message and click on Post Update button.

Private Messages
Private Messaging works like an internal site email. Members can message people on their friends list as well as reply to received messages. Each member will have their own individual Inbox and Sent messages folders as well as a Compose message screen. Members will be notified of new messages by a new message count in own Messages tab, in notification circle in Admin toolbar, as well as receive email notifications of the private message, if enabled.
Private Message Screens

Inbox – Shows the list of Private Message/s sent to your by members of the site. Visible to the logged in member only.Options

Search Messages
Read Message
Delete Message
Bulk Delete Messages – Select Read, Unread or All Messages

Sent – Shows the list of Message/s you have sent to other members of the site. Visible to the logged in member only.Options

Search Sent Messages
Read Sent Message
Delete Sent Message
Bulk Delete Sent Messages – Select Read, Unread or All Messages

Compose – Shows a form to send messages. Visible to logged in member only.Input

Send To (Username or Friend』s Name) field
Super Admin Only: Checkbox for 「This is a notice to all users.」
Subject field
Message field
Send Message button

Super Admin Only: Notices – Shows a list of Sitewide Notices broadcasted and date sent via Compose panel. The Super Admin』s notice will show up in the sidebar for logged in members only (BP Default theme) who in turn, can click on the 「Close」 link at the end of the notice – hopefully after they』ve read the message first. The following buttons are visible to the Site/Super Admin only.

Deactivate (notice) button
Delete (notice) button

How to Send a Private Message
Via member』s Private Message button

Go to the member』s profile page
Click on the Private Message button in the member』s header area and you will be redirected to your Messages > Compose screen
Member』s username is already entered as addressee
Enter the Title of your message
Enter content of your message
Click on the Send Message button
The logged in member will be notified about the message via Notification alert in the Admin Toolbar and via email if enabled.

Via your Account navigation in Admin Toolbar

Hover over your account Messages > click on Compose and you will be redirected to your Messages > Compose screen
Enter the username or the display name of your friend
Enter the Title of your message
Enter content of your message
Click on the Send Message button
The logged in member will be notified about the message via Notification alert in the Admin Toolbar and via email if enabled.

在插件中使用 BP Theme Compat

在插件中使用 BP Theme Compat

Codex Home → BuddyPress Plugin Development → Using BP Theme Compat in Plugins
Using BP Theme Compat in Plugins

A BuddyPress plugin can need to display content in several areas of a BuddyPress powered community :

In its own directory
In the member』s profile pages
In groups

The goal of this tutorial is to show you a way to take benefit of the magic that will be introduced in the next major release of BuddyPress (version 1.7) to maximize theme compatibility for BuddyPress content and for the content generated by your plugin.
In Plugin』s main directory.
When using the BP_Component class, we can specify that our plugin will have its own directory area. Here』s a quick reminder :
class BP_Plugin_Component extends BP_Component {

function __construct() {}
function includes() {
// Files to include
$includes = array(
/* some files */
'includes/bp-plugin-screen.php',
/*some other files */
);

parent::includes( $includes );
}

function setup_globals() {
$globals = array(
'slug' => 'some-slug',
'root_slug' => 'some-root-slug',
/* has_directory is set to true in order to setup plugin's main directory */
'has_directory' => true,
'notification_callback' => 'function_to_format_notification',
/* etc... */
);

parent::setup_globals( $globals );
}

function setup_nav() {}
function setup_admin_bar() {}
}

function bp_plugin_load_core_component() {
global $bp;

$bp->bp_plugin = new BP_Plugin_Component;
}
add_action( 'bp_loaded', 'bp_plugin_load_core_component' );

In this example, i』m using the file bp-plugin-screen.php in order to hold all the functions that will allow us to set the needed template for our plugin』s main directory.
So far, in order to indicate to BuddyPress the path to my plugin』s template, i used to filter the bp_located_template hook :

function bp_plugin_load_template_filter( $found_template, $templates ) {

//Only filter the template location when we're on the bp-plugin component pages.
if ( !bp_is_current_component( 'bp-plugin' ) )
return $found_template;

foreach ( (array) $templates as $template ) {
if ( file_exists( STYLESHEETPATH . '/' . $template ) )
$filtered_templates[] = STYLESHEETPATH . '/' . $template;
elseif( file_exists( TEMPLATEPATH . '/' . $template ) )
$filtered_templates[] = TEMPLATEPATH . '/' . $template;
else
$filtered_templates[] = BP_PLUGIN_DIR . '/templates/' . $template;
}

$found_template = $filtered_templates[0];

return apply_filters( 'bp_plugin_load_template_filter', $found_template );
}

add_filter( 'bp_located_template', 'bp_plugin_load_template_filter', 10, 2 );

We first check for our template file in the active theme or in the parent theme, and if nothing was found, we add to the templates array the path to our plugin template folder. Doing so, we allow themes to 「override」 and adapt the template to their design.
This done, in order to tell to BuddyPress to load the required template for my root plugin directory i filter the hook 『bp_screens『 :
function bp_plugin_screen_index() {
// i first check i'm on my plugin directory area...
if ( !bp_displayed_user_id() && bp_is_current_component( 'bp-plugin' ) && !bp_current_action() ) {
bp_update_is_directory( true, 'bp-plugin' );

//... before using bp_core_load_template to ask BuddyPress
// to load the template bp-plugin (which is located in
// BP_PLUGIN_DIR . '/templates/bp-plugin.php)
bp_core_load_template( apply_filters( 'bp_plugin_screen_index', 'bp-plugin' ) );
}
}
add_action( 'bp_screens', 'bp_plugin_screen_index' );

As you can see, when BuddyPress will run the function bp_core_load_template, which is located at line 346 of the /bp-core/bp-core-catchuri.php file (in BuddyPress 1.7-beta1), as soon as it meets the 『bp_located_template『 filter, my function 『bp_plugin_load_template_filter』 will step in to add my plugin template path. This is made possible thanks to line 379 of this file :
// Filter the template locations so that plugins can alter where they are located
$located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates );

In BuddyPress 1.7, this method is still working fine as soon as the community administrator is using the bundled BP Default theme or a child of it. But, if he decides to enjoy the 「BP Theme Compat」 great new feature in order to use any WordPress theme, then the content generated by our plugin will not display the best way.
To maximize this, we need to use the new hook introduced in the 1.7 version : do_action(『bp_setup_theme_compat』) which is located at line 410 of the bp_core_load_template function.
Actually, if BuddyPress haven』t found the required template then this hook is finally fired. Unlike what we』ve done just above, the funny part of this tutorial is that we first won』t tell BuddyPress what template to load if the active theme is not BP Default or a child of it.
In order to check if BP Default, or a child of it, or an eventual BuddyPress theme that is not relying on BP Default is active on the blog, i use this function :
function bp_plugin_is_bp_default() {
// if active theme is BP Default or a child theme, then we return true
// If the Buddypress version is < 1.7, then return true too
if(current_theme_supports('buddypress') || in_array( 'bp-default', array( get_stylesheet(), get_template() ) )  || ( defined( 'BP_VERSION' ) && version_compare( BP_VERSION, '1.7', ' 0,
'post_title' => 'BP Plugin Directory',
'post_author' => 0,
'post_date' => 0,
'post_content' => '',
'post_type' => 'bp_plugin',
'post_status' => 'publish',
'is_archive' => true,
'comment_status' => 'closed'
) );
}
/**
* Filter the_content with bp-plugin index template part
*/
public function directory_content() {
bp_buffer_template_part( 'bp-plugin' );
}
}

new BP_Plugin_Theme_Compat ();

Thanks to this step, we just made sure that BuddyPress will look for the bp-plugin template in the WordPress Theme or in the BP Legacy templates before trying to load it.
However, unless the active theme thought about adding this template, it won』t find it as it won』t check our plugin』s templates folder. We need to reference our plugin template folder first.
To do so, we can add a filter on the 「bp_get_template_stack」 hook in order to store our plugin path into the BuddyPress template paths :
function bp_plugin_add_template_stack( $templates ) {
// if we're on a page of our plugin and the theme is not BP Default, then we
// add our path to the template path array
if ( bp_is_current_component( 'bp-plugin' ) && !bp_plugin_is_bp_default() ) {

$templates[] = BP_PLUGIN_DIR . '/templates/';
}

return $templates;
}

add_filter( 'bp_get_template_stack', 'bp_plugin_add_template_stack', 10, 1 );

Doing so we make sure that if our template is not found in the WordPress active theme or in bp-legacy, it will be found in our plugin』s template folder. Finally we just need to adapt our plugin template in BP_PLUGIN_DIR . 『/templates/』 in order to strip the get_header, get_sidebar, and get_footer calls and to simply put our output into the new container tag 『

』. Now, if our template needs to load other template parts, we can use the new function bp_get_template_part to load it. Personally, i use a function that allows me to alternatively handle BP default or any WordPress theme in order to display my plugin content the best way :

function bp_plugin_locate_template( $template = false ) {
if( empty( $template ) )
return false;

if( bp_plugin_is_bp_default() ) {
locate_template( array( $template . '.php' ), true );
} else {
bp_get_template_part( $template );
}
}

In the member』s profile pages
We have two choices to load our plugin template in this area. First, we can take benefit of the different hooks bundled in the members/single/plugins.php BuddyPress template to inject our plugin』s content in its member area. Three hooks can be used :
do_action( 'bp_template_content_header' );
do_action( 'bp_template_title' );
do_action( 'bp_template_content' );

Back on our component class, when setting our plugin user navigation, we specify the screen function to play :
class BP_Plugin_Component extends BP_Component {

function __construct() {}
function includes() {}
function setup_globals() {}

function setup_nav() {

$main_nav = array(
'name' => __( 'BP Plugin' ),
'slug' => BP_PLUGIN_SLUG,
'position' => 80,
/* main nav screen function callback */
'screen_function' => 'bp_plugin_main_screen_function',
'default_subnav_slug' => 'bp-plugin-subnav'
);

// Add a few subnav items under the main tab
$sub_nav[] = array(
'name' => __( 'BP Plugin' ),
'slug' => 'bp-plugin-subnav',
'parent_url' => 'link to the parent url',
'parent_slug' => 'parent slug',
/* sub nav screen function callback */
'screen_function' => 'bp_plugin_main_screen_function',
'position' => 10,
);

parent::setup_nav( $main_nav, $sub_nav );
}
function setup_admin_bar() {}
}

Now in our bp-plugin-screen.php file, we need to write some code for our screen function in order to add actions when the three different hooks will be fired to display our content, for example :
function bp_plugin_main_screen_function {
add_action( 'bp_template_content_header', 'bp_plugin_menu_header' );
add_action( 'bp_template_title', 'bp_plugin_title' );
add_action( 'bp_template_content', 'bp_plugin_content' );

bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}

function bp_plugin_menu_header() {
_e( 'Menu Header' );
}

function bp_plugin_title() {
_e( 'Plugin title' );
}

function bp_plugin_content() {
_e( 'Plugin content');
}

We can use another approach by using a new template from our plugin』s template directory. However, unlike what we』ve accomplished earlier when we hooked 『bp_setup_theme_compat『 to display our root plugin directory content, we』ll use another method to modify the template to load as whatever happens, BP_Members_Theme_Compat will buffer the members/single/plugins template. So in our screen function, we first use the bp_core_load_template as it will be used in the BP Default case and as it will finally fire the bp_setup_theme_compat hook for any WordPress theme. Then we use our BP Default check in order to add a filter (if it returns false) to the bp_get_template_part function.
function bp_plugin_main_screen_function(){

bp_core_load_template( apply_filters( 'bp_plugin_main_screen_function', 'bp-plugin-main-user-template' ) );

//if BP Default is not used, we filter bp_get_template_part
if( !bp_plugin_is_bp_default() )
add_filter('bp_get_template_part','bp_plugin_user_template_part', 10, 3 );
}

function bp_plugin_user_template_part( $templates, $slug, $name ) {
if( $slug != 'members/single/plugins' )
return $templates;

return array( 'bp-plugin-main-user-template.php' );
}

Our bp_plugin_user_template_part will override the members/single/plugins.php BuddyPress template by our bp-plugin-main-user-template.php plugin template.
Finally, don』t forget to create the template BP_PLUGIN_DIR . 『/templates/bp-plugin-main-user-template.php』
In Group pages
here we just need to rely on the display function of the BuddyPress Group Api. In order to make sure our content will load the best way in BP Default or a child of it and any WordPress theme we can use our custom bp_plugin_locate_template function.
class BP_Plugin_Group extends BP_Group_Extension {

/** other function of group API **/

function display() {
bp_plugin_locate_template( 'bp-plugin-group-template' );
}
/** other function of group API **/

}

Finally, don』t forget to create the template BP_PLUGIN_DIR . 『/templates/bp-plugin-group-template.php』

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.

bp_member_user_id()

bp_member_user_id()

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

Description
Get the id of the user in a members loop.
If placed outside of a Members loop, it will be empty.
Usage
bp_member_user_id();

Parameters
None.
Example
Source File
bp_member_user_id() is located in bp-members/bp-members-template.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

.htaccess 重定向 FORCE_SSL_ADMIN

.htaccess 重定向 FORCE_SSL_ADMIN

Codex Home → Getting Started → .htaccess redirects for FORCE_SSL_ADMIN
.htaccess redirects for FORCE_SSL_ADMIN

This is a quick reference for anyone that is using FORCE_SSL_ADMIN in their wp-config.php to serve the admin dashboard and user login over https, but would like normal users to browse the frontend over http. BuddyPress implements its own set of redirect to parameters so that normal users are redirected back to the frontend after logging in rather than going straight to the admin dashboard (the default WP behavior). This makes sense as most BP users aren』t going to need to see the dashboard, but when FORCE_SSL_ADMIN is enabled this redirection includes https and causes regular users to browse the frontend over https.
One solution for fixing this is to use .htaccess rules to blanket redirect users who are not browsing the admin dashboard to the http version of your site. Below is some sample .htaccess rewrite rules that should redirect your users to http when they login. Your .htaccess file should be located in your document root, but may vary depending on your configuration.
Make sure that your redirect rules occur before the WordPress section (which is added if you use permalinks). Also, note that the rewrite condition you use to check for https may differ. For example, for some shared hosts you may need to use RewriteCond %{HTTP:X-Forwarded-SSL} on instead.
For more information on .htaccess rules and SSL check out this article.

# This is the additional rewrite section
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule !^wp-(admin/|login.php|includes/|content/)(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

用户扩展个人资料

用户扩展个人资料

Codex Home → Administrator Guide → User Extended Profiles
User Extended Profiles

Highlight the best of your community members by creating an unlimited number of Extended Profile (xProfile) Fields and/or groups of Extended Profile Fields custom-made for your social network.
To start creating xProfile fields, go to administration menu Users > Profile Fields. If you have a multisite installation with BuddyPress activated network-wide via Network Admin > Plugins, you』ll find the Profile Fields admin screen via Network Admin > Users > Profile Fields
Sections

Add New xProfile Field
Add New xProfile Field Group
Rearranging xProfile Fields or Field Groups

Add New xProfile Field

Fields marked * are required.
Fields in the 「Base」 (Primary) group will appear on the signup/register page.
Input
Field Title*
Field Description
Is this field required?
Select
Not Required
Required

Field Type:
Select
Single Line Text Box
Multi-line Text Box
Date Selector
Radio Buttons
Dropdown Select Box
Multiple Select Box
Checkboxes

Default Visibility
Options
Anyone (default)
Logged In Users
Admins Only
My Friends

Per-Member Visibility
Options
Let members change this field』s visibility {default)
Enforce the default visibility for all members

Save button, Cancel link

Edit Group button – allows you add, remove, move or change any xProfile field in the specific xProfile Group
Name (Primary)(Required) Field – Nice Name
Edit Field button – opens up a new screen
Input
Field Name (Required)
Field Description

Add New xProfile Field Group

The Add New Field Group button is located beside the Profile Fields component title. Click on the button to create a new Profile Group where you can later add more xProfile Fields

Title of xProfile Field Group
(Field) Group Description
Create Field Group button or Cancel link

Rearranging xProfile Fields or xProfile Field Groups
A. Change order of xProfile Fields within a Profile Field Group:
You can change the order by which xProfile Field/s show up in the Registration Form or in the Member』s Profile area by dragging the field up or down within the field group to the preferred location.

B. Change order of xProfile Field Groups:
You can change the order by which your xProfile Field Groups show up in Member』s Profile area by dragging the Group Tab to the left or right in Users > Profile Fields screen. Remember that only the Base (Primary) Field Group shows up in the Registration Form.

C. Move an xProfile Field from one xProfile Field Group to Another:
1. Click on the xProfile Field Group tab to open the panel where the xProfile Field you want to move is located.
2. Drag that xProfile Field to the xProfile Field Group tab where you want to move the xProfile Field.
3. You can then rearrange the position of the xProfile Field in new field group by dragging up or down to where you want to position the xProfile Field within the new group.