bp_core_new_nav_item()

bp_core_new_nav_item()

Codex Home → Developer Resources → Function Examples → Core Component → bp_core_new_nav_item()
bp_core_new_nav_item()

Description
Adds a navigation item to the main navigation array used in BuddyPress themes.
Example Usage
The snippet below is taken from bp-messages.php, and is used to add the main 「Messages」 link to the user navigation.
bp_core_new_nav_item(
array(
'name' => __('Messages', 'buddypress'),
'slug' => $bp->messages->slug,
'position' => 50,
'show_for_displayed_user' => false,
'screen_function' => 'messages_screen_inbox',
'default_subnav_slug' => 'inbox',
'item_css_id' => $bp->messages->id
));

As you can see above, this menu item is not displayed when viewing another users profile, it will call the 『messages_screen_inbox』 function when clicked, and will take you to your 『inbox』 sub navigation when clicked. It is also given the ID of the internal core component set from within BuddyPress, so that it can be styled later with an icon.
Parameters
name
String | Required | The display name for the navigation item.
slug
String | Required | The URL slug for the navigation item.
item_css_id
String | Optional/Recommended | Default: FALSE | The ID to give the navigation item in HTML for CSS styling.
show_for_displayed_user
Boolean | Optional | Default: TRUE | Determines if this navigation item appears when viewing another users profile.
site_admin_only
Boolean | Optional | Default: FALSE | Set to TRUE if a menu item is only to be seen by site admins (See is_site_admin())
position
Integer | Optional | Default: 99 | Index of where this navigation item appears in the list. Lower numbers appear sooner than higher numbers.
screen_function
String | Optional | Default: FALSE | Name of function to run when the navigation item is clicked.
default_subnav_slug
String | Required | Sets which sub navigation item is selected when this root navigation item is clicked. If you do not have sub navigation – use the same value used for slug.
Notes
It』s important to note that if either the 『slug』 or the 『name』 are omitted, this function will return false and no menu item will be created.
This function replaces bp_core_add_nav_item(), which was deprecated in BuddyPress 1.1.
Related Functions

bp_core_remove_nav_item()
bp_core_sort_nav_items() – deprecated since 2.6
bp_core_new_subnav_item()
bp_core_sort_subnav_items() – deprecated since 2.6
bp_core_remove_subnav_item()
bp_core_reset_subnav_items()

Source File
bp_core_new_nav_item() is located in bp-core/bp-core-buddybar.php

主题和 BuddyPress 模板包

主题和 BuddyPress 模板包

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

Archived file. Good up to BP 1.6.5 version

To enable your existing WordPress theme for BuddyPress, please download and activate the BuddyPress Template Pack plugin. This will run you through the process step-by-step.
The Process At-A-Glance
This requires a working knowledge of HTML and CSS at the very least.
After you install and activate the BP Template Pack plugin, head over to admin dashboard > Appearance > BP Compatibility panel.
Step One: Moving template files automatically
BuddyPress needs some extra template files in order to display its pages correctly. This plugin will attempt to automatically move the necessary files into your current theme.
Click the button below to start the process.
Move Template Files
Click on 「Move Template Files」 link
Templates moved successfully!
Great news! BuddyPress templates are now in the correct position in your theme, which means that we can skip Step Two: Moving Templates Manually, and move directly to Step Three. Cool!
Continue to Step Three.
Click on 「move on to step three」 link
Step Three: Tweaking your layout
Now that the template files are in the correct location, check out your site. (You can come back to the current page at any time, by visiting Dashboard > Appearance > BP Compatibility.) You should see a BuddyPress admin bar at the top of the page. Try visiting some of the links in the 「My Account」 menu. If everything has gone right up to this point, you should be able to see your BuddyPress content.
If you find that the pages are not quite aligned correctly, or the content is overlapping the sidebar, you may need to tweak the template HTML. Please follow the 「fixing alignment」 instructions below. If the content in your pages is aligned to your satisfaction, then you can skip to the 「Finishing Up」 section at the bottom of this page.
Fixing Alignment
By default BuddyPress templates use this HTML structure:

[ CONTENT ]

If BuddyPress pages are not aligned correctly, then you may need to modify some of the templates to match your theme』s HTML structure. The best way to do this is to access your theme』s files, via FTP, at:
/xxxxx/wp-content/themes/twentyeleven/
Open up the page.php file (if this does not exist, use index.php) of your active/preferred WP theme. Make note of the HTML template structure of the file, specifically the div tags that surround the content and sidebar.
There are two methods for making the necessary template changes.
A. The first method is to change the HTML structure in the following BuddyPress template files which were transferred into your active/preferred WP theme to match the structure of your WP theme』s page.php or index.php file.

/activity/index.php
/blogs/create.php
/blogs/index.php
/forums/index.php
/groups/index.php
/groups/create.php
/groups/single/home.php
/groups/single/plugins.php
/members/index.php
/members/single/home.php
/members/single/plugins.php
/members/single/settings/delete-account.php
/members/single/settings/general.php
/members/single/settings/notifications.php
/registration/activate.php
/registration/register.php

B. Alternatively, you may find it easier to make copies of your theme』s header.php, sidebar.php and footer.php and rename them to header-buddypress.php, sidebar-buddypress.php, and footer-buddypress.php.
Then you can alter the structure of these new template files (header-buddypress.php, sidebar-buddypress.php, and footer-buddypress.php) to resemble your theme』s page.php (or index.php).
Once you are done matching up the HTML structure of your theme in these template files, please take another look through your site. You should find that BuddyPress pages now fit inside the content structure of your theme.
Finishing Up
You』re now all done with the conversion process. Your WordPress theme will now happily provide BuddyPress compatibility support. Once you hit the finish button you will be presented with a new permanent theme options page, which will allow you to tweak some settings.
Finish
Click on 「Finish」 link
Final Steps
__Disable BP Template Pack CSS
The BuddyPress template pack comes with basic wireframe CSS styles that will format the layout of BuddyPress pages. You can extend upon these styles in your theme』s CSS file, or simply turn them off and build your own styles.
___Disable BP Template Pack JS / AJAX
The BuddyPress template pack will automatically integrate the BuddyPress default theme javascript and AJAX functionality into your theme. You can switch this off, however the experience will be somewhat degraded.
Save Settings
NOTE: To remove the 「BuddyPress is ready」 message you will need to add a 「buddypress」 tag to your theme. You can do this by editing the style.css file of your active theme and adding the tag to the 「Tags:」 line in the comment header.
Navigation Links
You may want to add new navigation tabs or links to your theme to link to BuddyPress directory pages. The default set of links are:

Activity: http://yoursite.com/activity/
Members: http://yoursite.com/members/
Groups: http://yoursite.com/groups/
Forums: http://yoursite.com/forums/
Register: http://yoursite.com/register/ (registration must be enabled)
Blogs: http://yoursite.com/blogs/

Reset Setup
If you would like to run through the setup process again please use the reset button (you will start at step three if you haven』t removed the template files):
Reset
Template-Packed WordPress Themes
Default WordPress Themes

Twenty Eleven Theme – BuddyPress Codex Walkthrough, BP 1.5, using second method
Twenty Ten Theme – BuddyPress Codex Walkthrough, BP 1.5, using second method

WordPress Themes Repository

Admire Theme – TBA
Admired Theme – http://wp.me/p1I84P-1l
Adventure Journal Theme – BuddyPress Forums
Atahualpa Theme – BuddyPress Forums
anIMass Theme – BuddyPress Forums
Canyon Theme – BuddyPress Forums
Catch Box Theme – BuddyPress Forums
DailyPost Theme – BuddyPress Forums
Delicate Theme – BuddyPress Forums
Easel Theme – http://wp.me/p1I84P-1y
Esplanade Theme – http://wp.me/p1I84P-31
Graphene Theme – BuddyPress Forums
iFeature Free – BuddyPress Forums
Mammoth Theme – BuddyPress Forums
Mantra Theme – BuddyPress Forums
Minimatica Theme – BuddyPress Forums
Motion Theme – BuddyPress Codex Walkthrough, first method
Mystique Theme – BuddyPress Forums
Pinboard Theme – http://wp.me/p1I84P-V
Platform Theme – BuddyPress Forums
PulsePress Theme – http://wp.me/p1I84P-3t
Sliding Door Theme – BuddyPress Forums
Thematic Child Theme – BuddyPress Forums
TP Sunrise Theme – BuddyPress Forums
Wallow Theme – http://wp.me/p1I84P-3x
Weaver Theme – BuddyPress Forums
WP Creativix Theme – BuddyPress Forums
Yoko Theme – http://wp.me/p1I84P-3b

Other WordPress Themes

13th Floor, Elegant Themes – BuddyPress Forums
Aggregate Theme, Elegant Themes – BuddyPress Forums
Alyeska Theme, Themeforest – BuddyPress Forums
Amplifier Theme, Themeforest – BuddyPress Forums
Artisteer Theme, Artisteer – BuddyPress Forums
Avenue Theme, Themeforest – http://wp.me/p1I84P-3J
Backstreet Theme, Themeforest – http://wp.me/p1I84P-1p
Basic Theme, Elegant Themes – http://wp.me/p1I84P-1u
BlackLight Theme, Theme Junkie – BuddyPress Forums
Blogging News Theme, Colorlabs – BuddyPress Forums
Bold Theme, Solostream – BuddyPress Forums
Boulevard Theme, Themeforest – BuddyPress Forums
Canvas Child Theme, Wootheme – BuddyPress Forums
Canyon Theme, Themeforest – BuddyPress Forums
CelebrityPress Theme, Gorilla Themes – http://wp.me/p1I84P-3z
Chameleon Theme, Elegant Themes – http://wp.me/p1I84P-3L
Collection Theme, Theme Junkie – http://wp.me/p1I84P-1B
Complete Theme, WP Explorer – http://wp.me/p1I84P-1n
Continuum Theme, Themeforest – http://wp.me/p1I84P-36
Delicious Magazine Theme, Woothemes – BuddyPress Forums
Denizen Theme, Themeforest – BuddyPress Forums
Diner Theme, Woothemes – BuddyPress Forums
Duotive Three, Themeforest – BuddyPress Forums
Eclipse Theme, Themeforest – http://wp.me/p1I84P-1g
eNews Theme, Elegant Themes – BuddyPress Forums
Envision Theme, Themefuse – BuddyPress Forums
Evolution Theme, Elegant Themes – BuddyPress Forums
Facepress Theme, Themeforest – http://wp.me/p1I84P-O
Flare Theme, Themeforest – http://wp.me/p1I84P-2P
Fullscreen Business Portfolio Theme, Themeforest – BuddyPress Forums
Gonzo Theme, Themeforest – http://wp.me/p1I84P-K
Harmony Theme, Elegrant Themes – http://wp.me/p1I84P-3R
iFeature4 Pro, Cyberchimps – BuddyPress Forums
Insignio Portfolio Theme, Themeforest – BuddyPress Forums: two columns, full width
InStyle Theme, Elegant Themes – old version at and Version 2.7 at http://wp.me/p1I84P-3H
Karma Theme, Themeforest – BuddyPress Forums
Listings, Woothemes – BuddyPress Forums
Lucid Theme, Elegant Themes – http://wp.me/p1I84P-E
Memo Theme, Premium Pixels – BuddyPress Forums
Merchant Theme, Themeforest – http://wp.me/p1I84P-1b
Metrolo Theme, ThemeState – BuddyPress Forums
Minimosity Theme, Themeforest – http://wp.me/p1I84P-2X
Modernize Theme, Themeforest – http://wp.me/p1I84P-1J
Music Theme, Netlabs – http://wp.me/p1I84P-18
MusicLife Theme, Fthemes – http://wp.me/p1I84P-1D
Neu Theme, ColorLabs – BuddyPress Forums
Nevada Theme, Themeforest – http://wp.me/p1I84P-34
Paradise Theme, Themeforest – http://wp.me/p1I84P-3r
Peekaboo Theme, Themeforest – BuddyPress Forums
Professional Theme, Elegant Themes – BuddyPress Forums
Puretype Theme, Elegant Themes – BuddyPress Forums
Quik Gallery, WP Explorer – BuddyPress Forums
Quickstart Theme, Gabfire – BuddyPress Forums
Ray of Light Theme, Themeforest – BuddyPress Forums
Reaction Theme, Themeforest – BuddyPress Forums
Risen Theme, Themeforest – BuddyPress Forums
Sahifa Theme, Themeforest – http://wp.me/p1I84P-3m
Shoutbox Theme, Themeforest – BuddyPress Forums
Simpfolio Theme, Slimmity – http://wp.me/p1I84P-3i
Smileth Theme, MyReviewPlugin – BuddyPress Forums
SMPL Theme, Woothemes – BuddyPress Forums
Sportsmag, Magazine3 – http://wp.me/p1I84P-3f
Strings Theme, Themeforest – http://wp.me/p1I84P-3o
Swagger Theme, Themeforest – http://wp.me/p1I84P-1F
Swatch Theme, Woothemes – BuddyPress Forums
Telegraph Theme, WPZoom – BuddyPress Forums
The Morning After Theme, Woothemes – http://wp.me/p1I84P-2Z
The Secret World Theme – http://wp.me/p1I84P-3F
The Source Theme, Elegant Themes – BuddyPress Forums
TheStyle Theme, Elegant Themes – BuddyPress Forums
Unstandard Theme, Themetie – BuddyPress Forums
Vagenta Theme, Themeforest – http://wp.me/p1I84P-2M
Volt Theme, Themeforest – http://wp.me/p1I84P-3k
Wallbase Theme, Web2Feel – BuddyPress Forums
Wikeasi Theme, WooThemes – BuddyPress Forums
Wisdom of Life Theme, Themeforest – http://wp.me/p1I84P-15
Wowway Theme, Themeforest – http://wp.me/p1I84P-38D
WP Bold, Solostream (partial – registration only) – http://wp.me/p1I84P-2U
WP Chatter Theme, Solostream – BuddyPress Forums
WP Church Theme, Themeforest – BuddyPress Forums
WP Clear Theme, Solostream – BuddyPress Forums
WP ClearPhoto Theme, Solostream – BuddyPress Forums
WP ClearVideo Theme, Solostream – BuddyPress Forums
WP DaVinci Theme, Solostream – http://wp.me/p1I84P-1H
WP Flexishop Theme, Themeforest – BuddyPress Forums
WordPress Theme 778, Template-help.com – BuddyPress Forums
yserif Theme, Yoarts.com – BuddyPress Forums

自定义标签、消息和 URL

自定义标签、消息和 URL

Codex Home → Getting Started → Customizing → Customizing Labels, Messages, and URLs
Customizing Labels, Messages, and URLs

Do you want to change various labels and messages in BuddyPress, but don』t want to hack the core files to do so? This page explains how to use a language translation file to customize BuddyPress labels, messages, and URL slugs.

Note: This is not intended for full language translations. If you intend BuddyPress to be used in a language other than English, see the Language Translations page.

Why use a language file?

The most compelling reason to use this method of changing labels and messages is to avoid hand-changing labels and messages in plugin and theme files. Even though theme customizations are recommended and encouraged, it is nice to have your customizations in one place. Overall, creating a custom language file is a better long-term solution than hand-changing plugin or theme files since you can make changes in one place for all labels and messages used in BuddyPress.

Labels and Messages

Here are the steps to create your own custom messages and labels without doing a full language translation.

This example uses en_US as the sample language definition and thus buddypress-en_US.mo is the name of the language file you will create. You』ll need to replace 『en_US』 with the locale of your WordPress site.

1. Create a customized PO file

Open the POT file in wp-content/plugins/buddypress/buddypress.pot, make a copy of the file and rename it to buddypress-en_US.po.

Then make the changes you want in a text editor or by using a specialized language localization editor like PoEdit (this is recommended if you are not comfortable using a text editor to make changes to the .po file).

Save your .PO file and generate a .MO file. The .MO file should be similarly named – buddypress-en_US.mo.

2. Uploading the PO and MO files

Now that you have generated your .MO file, move both the PO and MO files to /wp-content/languages/plugins/ on your server.

If the /wp-content/languages/plugins/ folder does not exist, create it!

3. Load the MO language file

WordPress 4.6 changed how language files are enqueued, preferring the GlotPress-provided 「canonical」 language file over a custom language file. The simplest way to make sure your new .mo file will be used is via a plugin available on the WordPress plugin repository: WPT Custom Mo File. Once you』ve activated the plugin, visit WP Admin > Tools > WPT Custom Mo File to upload your custom .mo file.

4. Test and verify your changes by loading BuddyPress.

Translating with PoEdit

PoEdit is a lightweight application for editing and creating .po and .mo files.

If you are not comfortable working at the command line then it is highly recommended to use this application.You can download PoEdit from http://www.poedit.net/download.php.

1) Download, install and start PoEdit

2) Select the BuddyPress translation file

On the main menu select 「File > New catalog from POT file」, navigate to the BP languages folder (/wp-content/plugins/buddypress/bp-languages/)and select the 『buddypress.pot』 file.

This will open a settings dialog and you will be asked to fill in some details such as project name which we』ll skip.

Click on 『OK』 and you』ll be asked to save your language file.

Save your language file as 「buddypress-en_US.po」. If you』re using a different language on WordPress, change 「en_US」 to the locale of your WordPress install.

3) Changing strings and saving the changes

Now, you will see a list of all the BuddyPress language strings you can modify.

Click on any string you wish to change and make the adjustment in the bottom half of the screen.

Go ahead and repeat this process for the other labels you want to change and when you』re done, hit 「Save」.

4) Uploading the PO and MO files

Follow steps #2 and #3 above.

Updating your custom language file

When a new version of BuddyPress is released, a new BuddyPress POT file is generated.

To remain up-to-date, you will need to merge this new file with your custom .po catalog.

You can do this by following these instructions:

1) Start PoEdit and go to 「File > Open」. Select your custom .po catalog file you created.

2) Now, go to 「Catalog > Update from POT file…」, and navigate to the /plugins/buddypress/buddypress.pot file (For older versions of BuddyPress, this file is located at /plugins/buddypress/bp-languages/buddypress.pot).

3) Opening the file will show an 「Update Summary」 window, which shows you the new strings added and the obsolete strings that will be removed. Click on 「OK」 and these changes will be merged into your .po file.

4) Then, simply save your catalog file once more to generate a new .mo file.

Slugs

For example, if you are running a sports website with BuddyPress, you could rename the URL slug example.com/members to example.com/players by changing the url of the corresponding component page in the WordPress admin -> pages.

To change slugs on the sub nav on a member page add these defines to a file bp-custom.php and place this file in /plugins/bp-custom.php

define( 'BP_SETTINGS_SLUG', 'settings' );
define( 'BP_XPROFILE_SLUG', 'profile' );

Loco Translate – Plugin solution

Loco Translate allows site admins to modify WordPress translations files of any theme and any plugin within the WordPress Dashboard. It also provides localization tools for developers, such as extracting strings and generating templates.

Go to Loco Translate plugin page

Notes

This is not intended for full language translations. If you intend BuddyPress to be used in a language other than English, see the Language Translations page.

This solution is arguably better than using the define ( 'WPLANG', ''); declaration in your wp-config.php file since we are really just trying to customize BuddyPress and not WordPress MU as a whole.

This page was inspired by a forum topic on BuddyPress.org called I want to speak Spotlish. View that thread for discussion and other suggestions.

私信循环

私信循环

Codex Home → Developer Resources → Loops Reference → Private Messages Loop
Private Messages Loop

The private messages loop can be used to output a user』s private messages, both from their inbox and sentbox.
Standard Loop

There are no messages to display.

Accepted Parameters
The bp_has_message_threads() function will accept a number of parameters that will manipulate the data being returned.

user_id optional
The ID of the user to fetch messages for. By default this will be the user_id of the user currently logged in.

Default value: $bp->loggedin_user->id

box optional
Which box should the loop display messages from?

Accepted arguments: inbox, sentbox, notices
Default value: inbox

per_page optional
The number of messages to display on a page before they are paginated to the next page.

Default value: 10

max optional
The total number of messages to return.

Default value: false (no limit)

Advanced Usage
Fetch inbox messages for the user of ID 12. Get a maximum of 5 messages.

修改工具栏

修改工具栏

Codex Home → Getting Started → User Submitted Guides → Deprecated Guides → Modifying the Toolbar
Modifying the Toolbar

Note: Modifying the Admin Bar requires a basic understanding of WordPress Hooks,Actions and Filters. If you aren』t familiar with these items, you can find more information on the WordPress Plugin API page.
The admin bar is a collection of individual functions, each of which implements a specific top level menu item that is displayed. If you look at the code in: /bp-core/bp-core-adminbar.php you』ll see these funcitons such as bp_adminbar_blogs_menu(). That creates the 『My Blogs』 menu item and all the items within the drop down menu.
We』re going to modify the 『My Blogs』 menu without changing the core code, thus helping to assure that our modifications don』t break when upgrading. We are going to sort the 『My Blogs』 menu items to have them appear in a specific order and eliminate the items that show up as 『Subscriber』.
The admin bar is triggered by wordpress 『actions』. These 『actions』 are events that are triggered throughout wp and bp. The admin bar responds to the action 『wp_footer』 which wp themes trigger at the end of each page in the theme footer. The admin bar registers it』s need to do something with the call to:
add_action( 'wp_footer', 'bp_core_admin_bar', 8 );

When the action 『wp_footer』 is triggered it will call the function named 『bp_core_admin_bar』. Looking at the function:
function bp_core_admin_bar() {
global $bp, $wpdb, $current_blog, $doing_admin_bar;

$doing_admin_bar = true;

if ( (int) get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
return false;

echo '<div id="wp-admin-bar">';

// **** Do bp-adminbar-logo Actions ********
do_action( 'bp_adminbar_logo' );

echo '<ul class="main-nav">';

// **** Do bp-adminbar-menus Actions ********
do_action( 'bp_adminbar_menus' );

echo '</ul>';
echo '</div>';
}

At first glance it doesn』t seem to do much. It does though. It defines its own action and triggers that action at the end of the function:
// **** Do bp-adminbar-menus Actions ********
do_action( 'bp_adminbar_menus' );

At the bottom of bp-core-adminbar.php you』ll notice a collection of add_action() calls that respond to 『bp_adminbar_menus』.
add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );

Each of the individual menu items responds to 『bp_adminbar_menus』. The one we are going to change is bp_adminbar_blogs_menu().
To change a function that is triggered by an action you have to unhook the current function that responds to the action and supply your own function that replaces the core function and then replace the add_action() call with one that responds to the same hook as the original function. This is how we』ll do that:
Original action hook:
add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );

Remove the action hook:
remove_action('bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6);

Replace the original action hook:
add_action('bp_adminbar_menus', 'my_adminbar_blogs_menu', 6);

Create a replacement function:
function my_adminbar_blogs_menu() {
if ( is_user_logged_in() ) {
global $bp;

if ( function_exists('bp_blogs_install') ) {

if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id, 'bp' ) ) {
$blogs = get_blogs_of_user( $bp->loggedin_user->id );
wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id, $blogs, 'bp' );
}

$blogs = filter_blogs_by_role($blogs);

[snip] the rest of the original function [snip]
}

I』ve made one change to the original function.
$blogs = filter_blogs_by_role($blogs);

After the call to get_blogs_of_user() we get an array of 『blog』 objects back from wp where the user has any role. I want to sort these blog objects to my liking and then just allow the rest of the function to run and display them.
I』ve decided to call my sort function filter_blogs_by_role() and it takes the array of blog objects, does something to them and then returns that filtered array of user blog objects. The rest of the function goes happily along to display our filtered results.
I』m not going to delve into what the filter_blogs_by_role() function does. I』ll just repeat it here. It sorts the blog objects by role with 『Admin』 appearing before all the other roles.
// sort array of blog objs by $blog->role according to the order of $blog_roles
// roles not included in $blog_roles array will not be displayed
function filter_blogs_by_role($blogs){
global $bp, $blog_roles;

$blog_roles[] = __( 'Admin', 'buddypress' );
$blog_roles[] = __( 'Editor', 'buddypress' );
$blog_roles[] = __( 'Author', 'buddypress' );
$blog_roles[] = __( 'Contributor', 'buddypress' );
$blog_roles[] = __( 'Subscriber', 'buddypress' );

// get roles
foreach ($blogs as $blog){
$blog->role = get_blog_role_for_user( $bp->loggedin_user->id, $blog->userblog_id );
}

// eliminate roles not in $blog_roles
foreach ($blogs as $key => $value){
if (!in_array($value->role, $blog_roles))
unset($blogs[$key]);
}

// sort by $blog_roles sequence if there are any left
if ($blogs){
usort($blogs, 'compare_roles');
}

return $blogs;
}

// helper function
function compare_roles($a, $b){
global $blog_roles;

foreach($blog_roles as $key => $value){
if($a->role==$value){
return 0;
break;
}

if($b->role==$value){
return 1;
break;
}
}

Now we have a replacement function called my_adminbar_blogs_menu(). We』ve got to hook it up so that it actually does replace the orignal call to bp_adminbar_blogs_menu();
Any custom code that we create can be placed in a file called bp-custom.php. It gets loaded with all the rest of bp automatically by bp during each page load. If you don』t have one already then create one in /wp-content/plugins/. So we』ll pretend that we have done just that and that our three new functions are going to be loaded with the rest of bp.
bp-custom.php

So we have our shiny new replacement function and we now need to determine how best to hook it up to the rest of the universe and make it work. There really isn』t a 『best』 way to do this. There are several ways to do it though.
I like to keep all my custom bp code in bp-custom.php so that』s how I』m going to implement this. Since the admin bar responds to 『wp_footer』, I』m going to hook that event and do some things before the admin bar is displayed.
In bp-custom.php:
function my_alter_bp_adminbar(){
remove_action('bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6);
add_action('bp_adminbar_menus', 'my_adminbar_blogs_menu', 6);
}
add_action('wp_footer','my_alter_bp_adminbar',1);

I』ve told wp that when it triggers the action 『wp_footer』 call the function my_alter_bp_adminbar() and do it with a priority of 『1』. A priority of 『1』 makes sure that it gets called before other functions that respond to 『wp_footer』.
If I add that to the other three functions I just stuffed into bp-custom.php then it will replace the original menu function with my new menu function and alter the behavior of bp when it displays the 『My Blogs』 menu.
Confusing enough for you? Welcome to event driven programming.
Other Articles on Modifying the Admin Bar
Limit Blog Creation to Admins

个人资料字段循环

个人资料字段循环

Codex Home → Developer Resources → Loops Reference → Profile Fields Loop
Profile Fields Loop

The profile data loop is the most complex out of all the custom BuddyPress loops. It』s actually two loops in one, the first is to loop through profile field groups, and the second to loop through profile fields in that profile field group.
Standard Loop

This user does not have a profile.

Accepted Parameters
The bp_group_has_profile() function will accept a number of parameters that will manipulate the data being returned.

profile_group_id optional
By default all groups and all fields will be displayed. If you provide the ID of a profile field group, then only the fields in this group will be displayed.

Default value: false

user_id optional
The ID of the user you want to fetch the profile data for. This is required if you are outside a member profile URL (/members/andy/…), otherwise it is the ID of the displayed user.

Default value: bp_displayed_user_id()

member_type optional
Limit fields by those restricted to a given member type, or array of  member types. If $user_id is provided, the value of $member_type will be overridden by the member types of the provided user. The special value of 『any』 will return only those fields that are unrestricted by member type – i.e., those applicable to any type.

Default value: false

hide_empty_groups optional
By default empty groups will not be displayed. If you provide the 0 value, then all the groups will be displayed.

Default value: true

hide_empty_fields optional
By default, only show empty fields if we』re on the Dashboard, or we』re on a user』s profile edit page, or this is a registration page. If you provide the 0 value, then all the fields will be displayed on your page.

Default value: !is_network_admin() && !is_admin() && !bp_is_user_profile_edit() && !bp_is_register_page()

fetch_fields optional
Whether to fetch each group』s fields.

Default value: false

fetch_fields_data optional
Whether to fetch data for each field. Requires a $user_id.

Default value: false

exclude_groups optional
Comma-separated list or array of group IDs to exclude.

Default value: array()

exclude_fields optional
Comma-separated list or array of field IDs to exclude.

Default value: array()

update_meta_cache optional
Whether to pre-fetch xprofilemeta for all retrieved groups, fields, and data.

Default value: true

Advanced Usage
Fetch all the profile data for the user with ID 10.

Fetch the profile data for fields in the profile group ID 2 for the user with ID 10.

Fetch the profile data for fields in the profile group ID 2.

Fetch all the profile data, even empty fieds and groups, for current user.

Fetch all the profile data for the user with ID 10, excluding fields with ID 5, 6, 7.

循环参考

循环参考

Codex Home → Developer Resources → Loops Reference
Loops Reference

Just as you use 「The Loop」 to loop through posts in WordPress, each content type in BuddyPress has its own custom loop.
By using these loops in your template, you can output any kind of information and really customize how content is displayed within your BuddyPress theme.
The default BuddyPress template files makes use of all the loops avaliable in BuddyPress. It provides a good example of using the loops in real use situations.

$bp 全局

$bp 全局

Codex Home → Developer Resources → The $bp Global
The $bp Global

The $bp global contains all of the variables and configuration settings that BuddyPress needs to use throughout an installation. As a developer you may find a good first step is to use the function below to render out the contents. You』ll then be able to look over everything and get a glimpse into how things work behind the scenes.
Add this to the top of 『bp-core.php』 and you』ll be able to take a good look at it:
function bp_dump() {
global $bp;

foreach ( (array)$bp as $key => $value ) {
echo '<pre>';
echo '<strong>' . $key . ': </strong><br />';
print_r( $value );
echo '</pre>';
}
die;
}
add_action( 'wp', 'bp_dump' );

Here』s an description of each setting:

$bp->root_components array
The slug of each component that can run in the root of the site. For example, 『groups』 is a root component because it can run both on http://example.org/members/andy/groups but also in the root: http://example.org/groups/my-group/. Settings can be added using the function bp_core_add_root_component( $component_slug )

$bp->root_domain string
The domain of the root blog on your WPMU installation.

$bp->loggedin_user object
Contains the ID, URL and name of the currently logged in user.

$bp->loggedin_user->id The user ID of the user.
$bp->loggedin_user->domain The profile page URL of the user
$bp->loggedin_user->fullname The display name of the user

$bp->displayed_user object
If you』re looking at a user』s profile page, or any page under http://example.org/members/[username]/ then displayed_user will hold the ID, URL and name of that user. If you』re not currently looking at a user these values will return false.

$bp->displayed_user->id The user ID of the user.
$bp->displayed_user->domain The profile page URL of the user
$bp->displayed_user->fullname The display name of the user

$bp->current_component string
The slug of the component that is currently being viewed. For example on the URL http://example.org/members/andy/messages/ the current_component would be messages. On http://example.org/groups/my-group current_component would be groups. If no component is being viewed (for example on the root) then current_component will equal $bp->default_component.

$bp->current_action string
The action being carried out within a component. Current action is usually always the next parameter in the URL after $bp->current_component. For example the URL http://example.org/members/andy/messages/view/345 current_action would be view. If $bp->current_component is in the list in $bp->root_components, and we are in the root (not /members/): http://example.org/groups/my-group/join current_action would be join where as my-group would be $bp->current_item.

$bp->action_variables array
Action variables are all the remaining sections of the URL after $bp->current_action. Each section (chunks of the URL between forward slashes) become an item in the array. For example the URL http://example.org/members/andy/groups/my-groups/leave/15 the values leave and 15 would each be items in the action_variables array.

$bp->current_item string
Only used when $bp->current_component is in the list of components in $bp->root_components. If we are working in the root of the install, but within a BuddyPress component, we need to offset $bp->current_action by one, to make way for a content item. For example: http://example.org/groups/my-group/join the current_item would be my-group as it is the current content item that we are viewing. $bp->current_action would then become join. Again, this is only when working in the root, and not under the /members/ slug.

$bp->is_single_item bool
This parameter is set as true if we are viewing a single content item in the root of an installation. For example, if we are viewing a group under the URL: http://example.org/groups/my-group/ then is_single_item will be true. This forces WordPress to use the currently active BuddyPress member theme to display the content, where as it would normally have used the active WordPress theme. If you created a custom component with a URL such as: http://example.org/muffins/chocolate/ you』d want to set $bp->is_single_item to true when viewing /chocolate/, so that the BuddyPress member theme can be used to display templates.

$bp->default_component string
When the user visits http://example.org/members/[username]/ which component should be shown? This is the slug value of that component.

Default: profile

$bp->bp_nav array
This is the array used to render each component navigation menu item for the logged in user. Each component is an item of the array, which in itself is an array containing three items (listed below). You can add to this array by using the function bp_core_add_nav_item().

$bp->bp_nav[]['name'] The display name for the component.
$bp->bp_nav[]['link'] The URL to the main page of the component – using the currently logged in user』s profile link.
$bp->bp_nav[]['css_id'] The CSS ID to use for the navigation item when it is rendered to the page in HTML.

$bp->bp_users_nav array
This is the array used to render each component navigation menu item for the displayed user (when you view a user that is not you). It follows the same format as $bp->bp_nav. This navigation array is different though, as it will not contain links to components that are only viewable by a logged in user (for example, messaging).

$bp->bp_users_nav[]['name'] The display name for the component.
$bp->bp_users_nav[]['link'] The URL to the main page of the component – using the currently displayed user』s profile link.
$bp->bp_users_nav[]['css_id'] The CSS ID to use for the navigation item when it is rendered to the page in HTML.

$bp->bp_options_nav array
This is the array used to render all of the sub navigation items for the $bp->bp_nav array. Each item is mapped to a top level nav item via its array key. Each sub level nav item contains the same options as the top level nav items, shown below.

$bp->bp_options_nav[]['name'] The display name for the sub-nav item.
$bp->bp_options_nav[]['link'] The URL to the main page of the component – using the currently logged in user』s profile link.
$bp->bp_options_nav[]['css_id'] The CSS ID to use for the navigation item when it is rendered to the page in HTML.

$bp->bp_options_title string
This is the title for the currently displayed sub-navigation item list. For example, when viewing the 「Messages」 component, the title of the sub-navigation item list would be 「My Messages」. If we were viewing a user』s profile other than ours, the title for the sub-navigation item list would be the name of the user.

$bp->bp_options_avatar string
This is the avatar associated with the sub-navigation item list. For instance, if we are viewing a user other than the user logged in, the avatar would be that user』s avatar. If we were viewing a group, the avatar would be that group』s avatar.

$bp->grav_default string
The default setting for gravatar type, when the user has no avatar or gravatar set. This is changed in the wp-admin area under 「BuddyPress > General Settings」.

$bp->is_item_admin bool
This setting can be used to give a user admin privileges on a particular piece of content. For site admins, this is always set to true, giving them override privileges on any content. For example, on the groups component, this is set to true if the currently logged in user is the creator of a group and that group is currently being viewed.

$bp->is_item_mod bool
Exactly the same as $bp->is_item_admin but for moderation privileges (basically a step down from admin privileges). This is used in the groups component for group moderators.

$bp->[component_name] object
Replace [component_name] with the name of a component and you will be able to access all of the settings for that component. Common settings for all components are listed below:

image_base The image directory for component specific images
table_name The name of the primary table used by the component
slug The URL slug for the component.
format_activity_function The function name that will format activity items into something readable by the end user.
format_notification_function The function name that will format notifications into something readable by the end user.

活动循环

活动循环

Codex Home → Developer Resources → Loops Reference → Activity Loop
Activity Loop

The activity loop can be used to output a list of sitewide, member or member』s friends activity.
Standard Loop

Accepted Parameters
The bp_has_activities() function will accept a number of parameters that will manipulate the data being returned.

scope optional
Pre-defined filtering of the activity stream. Show only activity for the scope you pass (based on the logged in user or a user_id you pass).

Accepted arguments: just-me, friends, groups, favorites, mentions
Default value: $bp->current_action

display_comments optional
Whether or not to display comments along with activity items. Threaded will show comments threaded under the activity. Stream will show comments within the actual stream in chronological order along with activity items.

Accepted arguments: false, threaded, stream
Default value: threaded

include optional
Pass an activity_id or string of comma separated ids to show only these entries.

Default value: false

sort optional
Sort the stream chronologically ascending or descending.

Accepted arguments: ASC, DESC
Default value: DESC

per_page optional
Number of activity items to show per page.

Default value: 20

page optional
Which page to return based on the number per page value.

Default value: 1

max optional
The limit on number of activity items that can be returned

Default value: false

show_hidden optional
Show items that have been hidden site wide? For example private or hidden group posts.

Default value: false

search_terms optional
Return only activity items that match these search terms

Default value: false

Filtering Options
Using filtering you can use the activity loop to return any specific information that has been recorded on the entire site. For example you could use it to return all of the latest comments site wide.
Listed below are the parameters you can use to filter the activity stream.

user_id optional
Limit activity items to a specific user ID. You can also pass in a comma separated string of user ids – see example below.

Default value: false (no filter)

object optional
The object type to filter on (can be any active component ID as well as custom component ID』s)

Example arguments: groups, friends, profile, status, blogs
Default value: false (no filter)

action optional
The action type to filter on (can be any active component action as well as custom component actions)

Example arguments: new_forum_post, new_blog_comment new_blog_post, friendship_created, joined_group, created_group, new_forum_topic, activity_update
Default value: false (no filter)

primary_id optional
The ID to filter on for a specific object. For example if you used groups as the object you could pass a group_id as the primary_id and restrict to that group.

Possible arguments: Any specific object ID
Default value: false (no filter)

secondary_id optional
The secondary ID to filter on for a specific object. For example if you used blogs as the object you could pass a blog_id as the primary_id and a post_id as the secondary_id the list all comments for that post using new_blog_comment as the action.

Possible arguments: Any specific object ID
Default value: false (no filter)

Filtering Examples
Filtering the activity loop to show only activity updates in the activity stream:

Use 『user_id』 to filter the activity loop to show only you and your friends in the activity stream:

Adding Commenting Support
Adding commenting support to your activity loop is pretty straightforward. You will first need to pass the 「display_comments=threaded」 parameter to your loop (see above).
Second you need to wrap all your activity code in a div with an 「activity」 class in order to make the ajax comments to work.
Finally, add the following code inside your loop, below 「activity-content」 div and above the closing list item tag:

<a href="" class="button acomment-reply bp-primary-action" id="acomment-comment-"><?php printf( __( 'Comment %s', 'buddypress' ), bp_activity_get_comment_count() ); ?>

<a href="" class="button fav bp-secondary-action" title="">

<a href="" class="button unfav bp-secondary-action" title="">

<form action="" method="post" id="ac-form-" class="ac-form">

<textarea id="ac-input-" class="ac-input" name="ac_input_">

<input type="submit" name="ac_form_submit" value="" />  
<input type="hidden" name="comment_form_id" value="" />

模板标签参考

模板标签参考

Codex Home → Developer Resources → Template Tag Reference
Template Tag Reference

This page is currently undergoing review and updating. References marked with ? have been reviewed for current accuracy.
General Template Tags

bp_get_loggedin_user_nav()
Deprecated
Uses the $bp->bp_nav global to render out the navigation within a BuddyPress install.
Each component adds to this navigation array within its own [component_name]_setup_nav() function.This navigation array is the top level navigation, so it contains items such as:
[Blog, Profile, Messages, Groups, Friends] …The function will also analyze the current component the user is in, to determine whether or not to highlight a particular nav item.
Since 1.1.0
bp_get_displayed_user_nav()
Uses the $bp->bp_users_nav global to render out the user navigation when viewing another user other than yourself.
Since 1.1.0
bp_get_options_nav()
Uses the $bp->bp_options_nav global to render out the sub navigation for the current component.
Each component adds to its sub navigation array within its own [component_name]_setup_nav() function.This sub navigation array is the secondary level navigation, so for profile it contains: [Public, Edit Profile, Change Avatar] The function will also analyze the current action for the current component to determine whether or not to highlight a particular sub nav item.@uses bp_get_user_nav() Renders the navigation for a profile of a currently viewed user.
Since 1.0.0
bp_get_options_title()
Deprecated
bp_site_name()
Returns the 『Site Title』 set in Settings > General.
Since 1.0.0
bp_is_home()
Deprecated since 1.5. Use bp_is_my_profile() instead.
Is the current page part of the profile of the logged-in user? Will return true for any subpage of the logged-in user』s profile, e.g. http://example.com/members/joe/friends/.
bp_last_activity()
Output the 「active [x days ago]」 string for a user.
See bp_get_last_activity() for a description of parameters.
Since 1.0.0
bp_user_link()
Deprecated. Use bp_displayed_user_domain() instead.
bp_get_loggedin_user_link()
Get the link for the logged-in user』s profile.
Since 1.0.0
bp_loggedinuser_link()
Output the link for the logged-in user』s profile.
Since 1.2.4
bp_get_displayed_user_link()
Get the link for the displayed user』s profile.
Since 1.0.0
bp_core_get_wp_profile()
Deprecated since 1.5.0.
bp_get_profile_header()
Deprecated since 1.7.0.
bp_exists()
Deprecated since 1.7.0.
bp_format_time()
Format a date based on a UNIX timestamp.
This function can be used to turn a UNIX timestamp into a properly formatted (and possibly localized) string, useful for outputting the date & time an action took place.
Not to be confused with `bp_core_time_since()`, this function is best used for displaying a more exact date and time vs. a human-readable time.
This function may be improved or removed at a later date, as it is hardly used and adds an additional layer of complexity to calculating dates and times together with timezone offsets and i18n.
Since 1.1.0
bp_word_or_name()
Select between two dynamic strings, according to context. This will display either a word, or a name to provide better context. for example, 「My friends」 or 「Bob』s friends」
This function can be used in cases where a phrase used in a template will differ for a user looking at his own profile and a user looking at another user』s profile (eg, 「My Friends」 and 「Joe』s Friends」). Pass both versions of the phrase, and bp_word_or_name() will detect which is appropriate, and do the necessary argument swapping for dynamic phrases.
Since 1.0.0
bp_get_plugin_sidebar()
Deprecated since 1.7.0.
This will try and find the file plugin-sidebar.php and display it if it』s found.
bp_is_page()
Deprecated since 1.7.0.
bp_is_blog_page()
Is this a blog page, ie a non-BP page?
You can tell if a page is displaying BP content by whether the current_component has been defined.
True if it』s a non-BP page, false otherwise.
Since 1.0.0
bp_page_title()
Deprecated since 1.5.0. Use wp_title()
bp_get_page_title()
Deprecated since 1.5.0. Use wp_title()
bp_styles()
Deprecated
bp_has_custom_signup_page()
Do we have a working custom sign up page?
True if page and template exist, false if not.
Since 1.5.0
bp_signup_page()
Output the URL to the signup page.
Since 1.0.0
bp_has_custom_activation_page()
Do we have a working custom activation page?
True if page and template exist, false if not.
Since 1.5.0
bp_activation_page()
Output the URL of the activation page.
Since 1.0.0
bp_search_form()
Deprecated since 1.1.0.
bp_search_form_action()
Return the 「action」 attribute for search forms.
Since 1.0.0
bp_search_form_type_select()
bp_login_bar() Removed/deprecated
bp_profile_wire_can_post()
This is deprecated, for more info, see the BuddyPress Backwards Compatibility plugin. Deprecated
bp_nav_items()
Deprecated This is deprecated, you should put these navigation items in your template header.php for easy editing.
bp_custom_profile_boxes()
Deprecated
bp_custom_profile_sidebar_boxes()
Deprecated
bp_get_userbar()
Deprecated
bp_get_optionsbar()
Deprecated
bp_is_directory()
Is this a component directory page?
True if the current page is a component directory, otherwise false.
Since 1.0.0
bp_create_excerpt()
Cuts a string to the length of $length and replaces the last characters with the ending if the text is longer than length.
This function is borrowed from CakePHP v2.0, under the MIT license. See http://book.cakephp.org/view/1469/Text#truncate-1625
Since 1.0.0
Fakes an excerpt on any content. Will not truncate words.
bp_is_serialized()
Checks to see if the data passed has been serialized.
bp_rewind_site_members
bp_has_site_members
bp_the_site_member
bp_site_members
bp_site_members_pagination_count
bp_get_site_members_pagination_links
bp_site_members_pagination_links
bp_get_the_site_member_user_id
bp_the_site_member_user_id
bp_get_the_site_member_avatar
bp_the_site_member_avatar
bp_get_the_site_member_link
bp_the_site_member_link
bp_get_the_site_member_name
bp_the_site_member_name
bp_get_the_site_member_last_active
bp_the_site_member_last_active
bp_get_the_site_member_registered
bp_the_site_member_registered
bp_the_site_member_add_friend_button
bp_get_the_site_member_total_friend_count
bp_the_site_member_total_friend_count
bp_the_site_member_random_profile_data
bp_the_site_member_hidden_fields
bp_directory_members_search_form
bp_home_blog_url

BP Member/User tags
bp_displayed_user_id()
bp_current_user_id()
bp_loggedin_user_id()
bp_core_get_user_domain() returns url to user account given a user id 『bp_loggedin_user_id』
bp_core_get_userlink() returns a fully rendered link to users account

bp_displayed_user_domain()
bp_loggedin_user_domain()
bp_user_fullname()
bp_displayed_user_fullname()
bp_get_loggedin_user_fullname()
bp_loggedin_user_fullname()

BP Component & Action checks

bp_current_component()
bp_current_action()
bp_action_variables()

Avatar Template Tags

bp_has_options_avatar()
Check to see if there is an options avatar. An options avatar is an avatar for something
like a group, or a friend. Basically an avatar that appears in the sub nav options bar.
bp_get_options_avatar()
bp_comment_author_avatar()
bp_post_author_avatar()
bp_loggedin_user_avatar()
bp_get_loggedin_user_avatar()
bp_displayed_user_avatar()
bp_get_displayed_user_avatar()
bp_avatar_admin_step()
bp_get_avatar_admin_step()
bp_avatar_to_crop()
bp_get_avatar_to_crop()
bp_avatar_to_crop_src()
bp_get_avatar_to_crop_src()
bp_avatar_cropper()

Signup Template Tags

bp_signup_username_value
bp_get_signup_username_value
bp_signup_email_value
bp_get_signup_email_value
bp_signup_with_blog_value
bp_get_signup_with_blog_value
bp_signup_blog_url_value
bp_get_signup_blog_url_value
bp_get_signup_blog_title_value
bp_signup_blog_title_value
bp_get_signup_blog_privacy_value
bp_signup_blog_privacy_value
bp_get_signup_avatar_dir_value
bp_signup_avatar_dir_value
bp_get_current_signup_step
bp_current_signup_step
bp_get_signup_avatar
bp_signup_avatar

Section under review/editing see below for more up to date references.
is_ functions
These is_ functions are used to determine the type of page currently being served within the template.

bp_is_user()
Used to determine if the current page is a user page.
Returns:
TRUE if current page is a user page
FALSE otherwise

bp_is_user_profile()Used to determine if the current page is a profile screen.

Returns:
TRUE if current page is a profile page
FALSE otherwise

bp_is_activity()Used to determine if the current page is the activity page.

Returns:
TRUE if current page is the activity page
FALSE otherwise

bp_is_blogs()Used to determine if the current page is the blogs page.

Returns:
TRUE if current page is the blogs page
FALSE otherwise

bp_is_wire()Used to determine if the current page is a wire page.

Returns:
TRUE if current page is a wire page
FALSE otherwise

bp_is_messagesUsed to determine if the current page is a messages page.

Returns:
TRUE if current page is a messages page
FALSE otherwise

bp_is_friends()Used to determine if the current page is a friends page.

Returns:
TRUE if current page is a friends page
FALSE otherwise

bp_is_group()Used to determine if the current page is the groups page.

Returns:
TRUE if current page is the groups page
FALSE otherwise

bp_is_settings_componentUsed to determine if the current page is the user settings page.

Returns:
TRUE if current page is the user settings page page
FALSE otherwise

bp_is_my_activityUsed to determine if the current page is the my activity page.

Returns:
TRUE if current page is the my activity page
FALSE otherwise

bp_is_friends_activity()Used to determine if the current page is a friends activity page.

Returns:
TRUE if current page is a friends activity page
FALSE otherwise

bp_is_profile_edit()Used to determine if the current page is the profile edit page.

Returns:
TRUE if current page is the profile edit page
FALSE otherwise

bp_is_change_avatar()Used to determine if the current page is the change avatar page.

Returns:
TRUE if current page is the change avatar page
FALSE otherwise

bp_is_group_single()Used to determine if the current page is a single group page.

Returns:
TRUE if current page is a single group page
FALSE otherwise

bp_is_group_home()Used to determine if the current page is a group homepage.

Returns:
TRUE if current page is a group homepage
FALSE otherwise

bp_is_group_create()Used to determine if the current page is a group create page.

Returns:
TRUE if current page is a group create page
FALSE otherwise

bp_is_group_admin_page()Used to determine if the current page is a group admin page.

Returns:
TRUE if current page is a group admin page
FALSE otherwise

bp_is_group_forum()Used to determine if the current page is a group forum page.

Returns:
TRUE if current page is a group forum page
FALSE otherwise

bp_is_group_forum_topic()Used to determine if the current page is a group form topic page.

Returns:
TRUE if current page is a group forum topic page
FALSE otherwise

bp_is_group_membersUsed to determine if the current page is a group members page.

Returns:
TRUE if current page is a group members page
FALSE otherwise

bp_is_group_invites()Used to determine if the current page is a group invite page.

Returns:
TRUE if current page is a group invite page
FALSE otherwise

bp_is_group_leave()Used to determine if the current page is a 』leave the group』 page.

Returns:
TRUE if current page is a 』leave the group』 page
FALSE otherwise

bp_is_my_blogsUsed to determine if the current page is the my blogs page.

Returns:
TRUE if current page is the my blogs page
FALSE otherwise

bp_is_create_blog()Used to determine if the current page is the 』create a blog』 page.

Returns:
TRUE if current page is 』create a blog』 page
FALSE otherwise

bp_is_friends_screen()Used to determine if the current page is the friends page.

Returns:
TRUE if current page is the friends page
FALSE otherwise

bp_is_friend_requests()Used to determine if the current page is the friend requests page.

Returns:
TRUE if current page is the friend requests page
FALSE otherwise

bp_is_messages_inbox()Used to determine if the current page is the messages inbox page.

Returns:
TRUE if current page the messages inbox page
FALSE otherwise

bp_is_messages_sentbox()Used to determine if the current page is the messages sentbox page.

Returns:
TRUE if current page is the messages sentbox page
FALSE otherwise

bp_is_messages_conversation()Used to determine if the current page is a single messages conversation.

Returns:
TRUE if the current page is a single messages thread
FALSE otherwise

bp_is_notices()Used to determine if the current page is the notices page.

Returns:
TRUE if current page is the notices page
FALSE otherwise

bp_is_messages_compose_screen()Used to determine if the current page is the message compose page.

Returns:
TRUE if current page is the message compose page
FALSE otherwise

bp_is_register_page()Used to determine if the current page is the registration page.

Returns:
TRUE if current page is the registration page
FALSE otherwise

bp_is_activation_page()Used to determine if the current page is the activation page.

Returns:
TRUE if current page is the activation page
FALSE otherwise

Conditional template tags allow you to show specific content on specific pages. The following tags are available in BuddyPress (1.2+):

is_buddypress()
A generic check for buddypress screens.

Returns:
TRUE if current screen is a BP one
FALSE otherwise

bp_is_user()
Used to determine if the current page is a user page.

Returns:
TRUE if current page is a user page
FALSE otherwise

bp_is_user_profile()
Used to determine if the current page is a profile screen.

Returns:
TRUE if current page is a profile page
FALSE otherwise

bp_is_my_profile()
Used to determine if this is a profile component screen

Returns:
TRUE if current page is a profile page
FALSE otherwise

bp_is_blog_page()
A catch all for a WP blog page in BP.

bp_is_directory()
bp_is_serialized($data) – checks to see if $data is serialized
bp_is_front_page()
bp_is_activity_front_page()
bp_is_page($page) // deprecated 1.7 use bp_is_current_component( 『activity』 )
bp_is_current_component( 『activity』 ) ?
bp_is_active( $component ) – checks if a BP $component is active ?
bp_is_profile_component()
bp_is_activity_component()
bp_is_blogs_component()
bp_is_messages_component()
bp_is_friends_component()
bp_is_groups_component()
bp_is_settings_component()
bp_is_user_activity()
bp_is_user_friends_activity()
bp_is_activity_permalink() // deprecated 1.5 use bp_is_single_activity()
bp_is_user_profile()
bp_is_profile_edit()
bp_is_change_avatar()
bp_is_user_groups()
bp_is_group()
bp_is_group_home()
bp_is_group_create()
bp_is_group_admin_page()
bp_is_group_forum()
bp_is_group_activity()
bp_is_group_forum_topic()
bp_is_group_forum_topic_edit()
bp_is_group_members()
bp_is_group_invites()
bp_is_group_membership_request()
bp_is_group_leave()
bp_is_group_single()
bp_is_user_blogs()
bp_is_user_recent_posts()
bp_is_user_recent_commments()
bp_is_create_blog()
bp_is_user_friends()
bp_is_friend_requests()
bp_is_user_messages()
bp_is_messages_inbox()
bp_is_messages_sentbox()
bp_is_notices()
bp_is_messages_compose_screen()
bp_is_single_item()
bp_is_activation_page()
bp_is_register_page()
If you wanted to see if this was a single group page, in your template you could do:
Show this on group home pages
Or if you wanted to show something on every single group page, regardless if it was the home page or not:
Show this on all single group pages
There are no specific checks on group names etc yet, but you can do this:
This is my-group