为您的 BuddyPress 论坛使用现有的 bbPress 安装

为您的 BuddyPress 论坛使用现有的 bbPress 安装

Codex Home → Legacy Docs → Archived Section: Getting Started → Using an existing bbPress installation for your BuddyPress Forums
Using an existing bbPress installation for your BuddyPress Forums

Archived file. Good only up to BP 1.5 version

***The following pertains to sites wanting to use an existing bbPress installation (v1.x) with BuddyPress***
*** NOTE: This is a very rare scenario!  You will not need to follow this guide unless you are running a bbPress 1.x install on your site! ***
If you choose to enable group forums on BuddyPress, you will have the option to 「Set up a new bbPress Installation」 or to 「Use an existing bbPress installation「.
What does this mean necessarily?
If you don』t have a standalone, existing version of bbPress 1.x installed somewhere, then all you have to do is click on 「Set up a new bbPress installation「. Stop reading this article! You』re done!
Now, if you have an existing bbPress 1.x install, you have a choice to make.
Set Up a New bbPress installation
Pros

Easy setup, no headaches

Cons

Creating a new set of bbPress tables in your database solely for BuddyPress forum usage. This means you』ll have two sets of bbPress tables.

Use an existing bbPress installation
Pros

Use your existing bbPress install, maintain one set of bbPress tables

Cons

You will have duplicate forum posts: One on the BuddyPress side, the other on your standalone bbPress install
By default, BuddyPress group forums and group forum posts, regardless of privacy setting, will be posted publicly on your existing bbPress installation (don』t worry though, if you still want to go ahead with this, a detailed tutorial to hide BuddyPress group forums from your existing bbPress install is listed right underneath)

***Regardless of which choice you make, by default, there will be two entry points for forums. Your existing bbPress install URL and the BuddyPress global forums URL (eg. http://testbp.org/forums).***
Still want to go ahead with using an existing installation? Go ahead and click on 「Use an existing bbPress installation」 and follow the steps.
Then, implement the following to ensure your BuddyPress group forums are not publicly displayed on your existing bbPress install.
1) Change the forum slug in BuddyPress (optional)
By default, BuddyPress forums can be accessed at:
hxxp://example.com/forums/
If your existing bbPress install is also installed in /forums/, you』ll want to rename BuddyPress』 forums slug to something else.
You can do this by adding the following line in your wp-config.php:
?1define( 'BP_FORUMS_SLUG', 'group-forums' );
In the example above, your BP forums can now be accessed at hxxp://example.com/group-forums/
2) Create a new forum category in standalone bbPress
By default, BuddyPress will create new forums in your existing bbPress install under forum id #1 . We do not want to do this. So we』re going to create a new forum category to house these new BuddyPress forums.

First, login to your existing bbPress admin area and click on 「Forums」.
Next, scroll down and create a new forum category. You can call this forum category 「Group Forums」 or whatever you want! Under 「Make this forum a category」, ensure that this is checked.
Note down the forum ID of the forum category you just created. (You can get the forum category ID by mousing over the 「Edit」 link and checking the 「id」 parameter.)

3) Tell BuddyPress to use this new forum category
In step #2, we created a new, forum category to house our BuddyPress group forums. Now we want to tell BuddyPress to use this new forum category.
This can be done by adding the following define to wp-config.php:
?1define ( 'BP_FORUMS_PARENT_FORUM_ID', $forum_id );
Change $forum_id to the forum ID from step #2. Now, all new BuddyPress group forums will be created in standalone bbPress under this new forum category.
3) Hide BuddyPress group forum data in standalone bbPress
Now, the last issue we have is hiding all BuddyPress group forum related data from access and view on your existing bbPress installation.
We』re going to be using _ck_』s Hidden Groups plugin to do this. Please install and activate the plugin on your existing bbPress install.
Next:

Open up the plugin (hidden-forums.php) in a text editor.
Comment out this line:
?1$hidden_forums['hidden_forums']=array(500,501,502); // hide these forums, list by comma seperated number

Underneath that line, add the following:
?12345678910$bp_hide_group_forum_category_id = $forum_id; $hidden_forums['hidden_forums']=array();$hidden_forums['hidden_forums'][] = $bp_hide_group_forum_category_id; $forums = get_forums();foreach ($forums as $forum) {    if ($forum->forum_parent == $bp_hide_group_forum_category_id)        $hidden_forums['hidden_forums'][] = $forum->forum_id;}

Change the $bp_hide_group_forum_category_id variable to the forum category ID you noted down in step #2.

And that should be it! By default, the admin can view every single forum post on your bbPress install, so try viewing your bbPress install when you』re logged out!
* Posted by r-a-y, July 16, 2010. This how-to was originally based on this forum post.

Deleting BuddyPress

Deleting BuddyPress

Codex Home → Getting Started → Deleting BuddyPress
Deleting BuddyPress

So you』ve decided to stop using BuddyPress. That』s too bad. If something went wrong during your installation or if you ran into its 「limitations」 make sure to check out:
– The Support Forum for help
– The Plugin Directory for awesome BuddyPress plugins.
If you still want to stop using BuddyPress you can just follow these steps below.
Step 1: Disable all BuddyPress related plugins.
It』s a good idea to start with disabling and removing all the plugins on your site which need BuddyPress to function. Certain older plugins might give you a blank page when being active without BuddyPress being enabled. Go to your admin panel and visit the Plugins page. Disable all the plugins related to BuddyPress.

Step 2: Disable BuddyPress and delete the plugin files.
Once again go to your Plugin page and disable BuddyPress the same way as you disable the BuddyPress related plugins. Click the 「disable」 button and you now have disabled BuddyPress.

If you encounter a white page after disabling BuddyPress take a close look at your plugins. Are you sure none of them need BuddyPress to function? If you』re sure that no BuddyPress related plugins are active check if the currently active Theme is not a BuddyPress Theme. If you do have a BuddyPress Theme as your active theme, rename or delete the theme from your Theme folder, so that WordPress resets to the default theme.
Finally you can remove the BuddyPress files by clicking on the 「delete」 button on the plugin page.
You have now successfully removed BuddyPress!
Advanced Optional Step: Removing the database tables
Warning: Make sure to backup your database first! Making a mistake during this process can result in a broken or entirely removed database! If you are not comfortable using PHPMyAdmin do not even go here. Mistakes are made fast so be careful! A guide to backing up a WP DB can be found here: codex.wordpress.org/Backing_Up_Your_Database
Open up PHPMyAdmin through your webhosting panel (cPanel, Plesk or any other system) and visit your WordPress database. Select all the database tables that have WP_BP_ as prefix. If you have chosen a different table prefix during your WordPress installation they can be named differently. The structure is always like this: [table prefix]_BP_
If you have BuddyPress dependent plugins installed you might want to scan your database for any additional unneeded tables, but make sure you』re not dropping a table which is needed for a plugin to function!

When you』ve selected all these tables use the dropdown at the bottom of the page and select 「Drop Tables」 and press the 「Go」 button.

BuddyPress is now completely removed including its database tables.
Advanced Optional Step: Removing BuddyPress』 options from the wp_options table
Warning: Make sure to backup your database first! Making a mistake during this process can result in a broken or entirely removed database! If you are not comfortable using PHPMyAdmin do not even go here. Mistakes are made fast so be careful! A guide to backing up a WP DB can be found here: codex.wordpress.org/Backing_Up_Your_Database
N.B. An additional step that you might like to take if editing tables and working in phpMyAdmin is to use it』s ability to make a full copy of an existing DB under a new name, doing this allows you to simply switch your wp-config DB entry to point to the copied DB for a quick recovery should things go wrong; you are, however, still advised to take a sql backup dump as well for total peace of mind.
Open up PHPMyAdmin through your webhosting panel (cPanel, Plesk or any other system) and visit your WordPress database.
Navigate to the WordPress options table. (By default, this is the 「wp_options」 table, but might be different if you changed your database prefix.)
Next, find the following entries under the option_name column:

bp-db-version (for BuddyPress 1.5)
_bp_db_version (as of BuddyPress 1.6)
bp-active-components
bp-blogs-first-install
bp-deactivated-components
bp-disable-account-deletion
bp-disable-avatar-uploads
bp-disable-blogforum-coments
bp-disable-profile-sync
bp-pages
bp-xprofile-base-group-name
bp-xprofile-fullname-field-name

And delete them from the database.

导航链接返回 404 错误

导航链接返回 404 错误

Codex Home → Legacy Docs → Archived Section: Getting Started → Navigation Links Return 404 Errors
Navigation Links Return 404 Errors

A common error after installation of BuddyPress from within the WordPress admin panel is to not set pretty permalinks. If you fail to do this then all of the links in the header will return 404 errors.
To fix this problem, enter the WordPress admin panel > Settings > Permalinks – set to any configuration other than the default configuration. The mod_rewrite must be enabled on your server for pretty permalinks to work.

主题兼容性模板包 (v1.2)

主题兼容性模板包 (v1.2)

Codex Home → Legacy Docs → Archived Section: Theme Development → Themes & the BuddyPress Template Pack → Template Pack for Theme Compatibility (v1.2)
Template Pack for Theme Compatibility (v1.2)

Archived file. Good only up to BP 1.6.5 version

To enable compatibility for your existing WordPress theme with 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
BuddyPress needs some extra template files in order to display its pages correctly. This plugin contains these extra templates, but right now they are in the plugin directory. They need to be inside your active theme directory to work correctly. First of all we can try moving them automatically, please click the button below to attempt to move the templates:
Move Template Files
Click on 「Move Template Files」 link
Step Two
Templates moved successfully! This is great news, BuddyPress templates are now in the correct position in your theme which means you can skip step two and move on to step three.
Click on 「move on to step three」 link
Step Three
Now that the template files are in the correct location, click through your site (you can come back to this page at any point). You should see a BuddyPress admin bar at the top of the page, try visiting some of the links in the 「My Account」 menu. You should find that BuddyPress pages now work and are displayed.
If you find that the pages are not quite aligned correctly, or the content is overlapping the sidebar, you will need to tweak the template HTML. Please follow the 「fixing alignment」 instructions below. If the content in your pages is aligned in the correct place 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:
[HEADER]

[PAGE CONTENT]
[SIDEBAR CONTENT]

[FOOTER]

If BuddyPress pages are not aligned correctly then you will need to modify some of the templates to match your theme』s HTML structure. The best way to do this is to FTP to your theme』s files at:
http://yoursite.com/wp-content/themes/active-WordPress-theme-folder/
Then open up the page.php file (if this does not exist use index.php). Make note of the HTML template structure of the file, specifically the

tags that surround the content and sidebar.
You will need to change the HTML structure in the BuddyPress templates that you copied into your theme to match the structure in your page.php or index.php file. The files that you need to edit are as follows (leave out any folders you have not copied over in step two):

activity/index.php
blogs/index.php
blogs/create.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
registration/register.php
registration/activate.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 allowing you to tweak some settings.
Finish
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
Example

BP Template Pack Walkthrough – Easy Level

groups_get_groupmeta()

groups_get_groupmeta()

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

Function to get custom group meta.
If you don』t pass a meta_key it returns ALL meta data associated with that group_id.
Returns String or Array of Meta Values.
Odd Behavior: If you pass no meta key to get all values and it has none, it returns a blank array. If you passed a key it returns a blank string.
groups_get_groupmeta( $group_id, $meta_key = '');
See also groups_update_groupmeta()
Source File
groups_get_groupmeta() is located in bp-groups/bp-groups-functions.php

Persian – Farsi (fa_IR)

Persian – Farsi (fa_IR)

Codex Home → Languages and Translations → Persian – Farsi (fa_IR)
Persian – Farsi (fa_IR)

BuddyPress translations can be downloaded at bp-parsi.com while awaiting confirmation at the official translation repository at https://translate.wordpress.org/projects/buddypress/dev/fa/default
Download Persian translation

Importing Data

Importing Data

Codex Home → Getting Started → Importing Data
Importing Data

Importing from Ning
Many users have been interested in being able to import their Ning social network into BuddyPress. This has been even more true since Ning started charging to use their service. Much of the heavy lifting of importing your Ning network to BuddyPress can be done using this Import from Ning Plugin.

空白页

空白页

Codex Home → Getting Started → Troubleshooting → Blank Pages
Blank Pages

In some server environments, installation of BuddyPress can lead to blank pages. A great source for troubleshooting this problem is the error logs.
Memory Limit
Increasing the available memory may fix the blank page problem. Three methods are available for increasing the memory limit.
php.ini
If possible, increase the memory limit within the php.ini file.
wp-config.php
If possible, increase the memory limit in the wp-config.php file by adding define ('WP_MEMORY_LIMIT', '64M');.
.htaccess
If possible, add the following to the .htaccess file: php_value memory_limit 256M
talk to your host
If you cannot resolve increasing memory with the fixes above, it means that your hosting provider prevents increases in memory limits. Contact tech support right away. Some hosting providers might require you to upgrade your plan or pay extra.
Clear your browser cache or try another browser
After increasing memory, be sure to clear your browser cache. Also, troubleshoot multiple browsers and multiple user roles (subscriber, author, admin, etc.)
Database Tables
Other things stopping the DB tables being run is some sort of warning or error with PHP – often either a memory limit, CPU limitation, a problem with the web server itself, bad code or corrupt file.
1) Memory limit problem often reveals itself with 「failed to allocate」 in the apache/php error logs.
2) People have had mixed success running WPMU/BP on virtual hosted servers; I suppose it depends on the company you are using. If such an outside influence stopped activity *part way* through the BuddyPress installation, then you』d end up with a corrupt install. As a rule of thumb, avoid virtual hosted servers for WPMU/BP.
3) I』m a *unix man as far as web servers go, so I can』t talk for Windows. If you see 「segfault」 errors in WPMU/BP for Apache (or similar), you』ve probably got a library or versioning conflict — i.e. incompatibility between specific versions of PHP and MySQL, for example. These are really tricky to figure out what』s causing the problem, but if you』ve recently installed a new version of your web server/mysql/php etc, this could be why.
4) Bad code or corrupt file – how is everyone in this thread installing BuddyPress? Via the automatic plugin installer? If so, try to FTP files up to your server – or better yet, SSH and use a shell to install the files yourself.
Source
XAMP and MAMP
Testing servers built with XAMP or MAMP should use the latest versions.

模板包演练 – Twenty Eleven

模板包演练 – Twenty Eleven

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

Archived file. Good only up to BP 1.6.5 version

BP TEMPLATE PACK 1.2 == BUDDYPRESS 1.5 == WORDPRESS 3.2.1

There are two ways to implement Step Three of the compatibility process:
– First Method: Superimposing the HTML structure of your WordPress theme onto 16 BP template files which were transferred into your WP theme folder during the compatibility process or
– Second Method: Creating the following files in your WordPress theme – header-buddypress.php, sidebar-buddypress.php and/or footer-buddypress.php
We』ll use the second method to make Twenty Eleven compatible with BuddyPress. By the end of this article, you should have the basic child theme files required to make Twenty Eleven compatible with BP 1.5 using the BP Template Pack plugin:

/bp-twentyeleven/

header-buddypress.php
sidebar-buddypress.php
style.css

Prelude: Create a Twenty Eleven Child Theme
( If you already have your own Twenty Eleven Child theme, skip this section and proceed to the Compatibility Process )
1. Create a new theme folder for your Twenty Eleven child theme. For this example, the child theme is called BP Twenty Eleven so we』ll name our theme folder bp-twentyeleven.
2. Create a style.css file and add it in the bp-twentyeleven folder with content below:

/*
Theme Name: BP Twenty Eleven
Theme URI: https://codex.buddypress.org/
Description: Twenty Eleven child theme for BuddyPress Compatibility Process
Version: 1.0
Author: mercime
Author URI: https://codex.buddypress.org/
Template: twentyeleven
Tags: buddypress, two-column
*/
@import url( ../twentyeleven/style.css );

3. Upload the bp-twentyeleven folder with the style.css file within to your server at /wp-content/themes/
N.B. We』ll be creating and uploading more files later during the compatibility process. For now, these are the basic files required for the child theme to be activated so that we can proceed with the BP compatibility process.
Compatibility Process
1. After activating BuddyPress, go to dashboard Appearance > Themes and activate our child theme 「BP Twenty Eleven. At the top of the Themes panel, you』ll see a message with 3 different options to make your theme compatible with BuddyPress. Select update your existing WordPress theme

2. Clicking on the above link will bring you to the 「Install Plugins」 panel. Click on 「Install」 link under BuddyPress Template Pack plugin.

3. Click OK to install BuddyPress Template Pack plugin.

4. Activate BuddyPress Template Pack plugin.

5. Go to Appearance > BP Compatibility

6. Step One: Moving template files automatically. Click on Move Template Files

7. Templates moved successfully! Click on Continue to Step Three You only need to go through Step Two if there was a problem transferring the files.

Pages: 1 2 3

如何编辑群组元数据教程

如何编辑群组元数据教程

Codex Home → BuddyPress Plugin Development → How to Edit Group Meta Tutorial
How to Edit Group Meta Tutorial

This tutorial will show you how to add a custom field to the registration process as well as the admin->」edit details」 section. I will also show you how to print that out into the header and how to echo that data elsewhere.
We are going to do this as a standalone plugin but you could easily add this to your existing plugins or even your functions.php (without the plugin header data)
Firstly create a folder in your wp-contents/plugins folder. Call it whatever you want this plugin to be called. Lets call ours 「Favorite Color」 Then create a file inside. Mines called favorite_color.php Open that file up and start with:


<input id="favorite-color" type="text" name="favorite-color" value="" />

<?php
}

This outputs a label and input field that gets added to the already existing form during registration and editing. That』s why there is no input or other form data.
We created the id and name based upon  whatever we want to name the field. We then call our custom_field() function with that meta data to see if a value already exists. It wont return anything during the signup process but it will afterwards.
// This saves the custom group meta – props to Boone for the function
// Where $plain_fields = array.. you may add additional fields, eg
//  $plain_fields = array(
//      'field-one',
//      'field-two'
//  );
function group_header_fields_save( $group_id ) {
global $bp, $wpdb;
$plain_fields = array(
'favorite-color'
);
foreach( $plain_fields as $field ) {
$key = $field;
if ( isset( $_POST[$key] ) ) {
$value = $_POST[$key];
groups_update_groupmeta( $group_id, $field, $value );
}
}
}

This is a pretty hefty function. It takes the passed data and saves it into the group meta. The reason they use the array and the foreach statement is in the event you want to add multiple fields. It would be a pain to rewrite the code over and over. this way you simply add a comma and a new field name. It then checks to see if there is a post object with the same name. (which if coming from the registration or edit forms we hooked into earlier it will) It then updates the meta accordingly.
Now we hook our functions into BuddyPress:
add_filter( 'groups_custom_group_fields_editable', 'group_header_fields_markup' );
add_action( 'groups_group_details_edited', 'group_header_fields_save' );
add_action( 'groups_created_group',  'group_header_fields_save' );

The first fires any time there is editable fields in BuddyPress and adds our nice input form. The next two are added when any of that data is normally posted and saved.
At this point you should be able to test your plugin. Activate it from the plugin menu and then attempt to create a group. Your field should show up at the bottom. Enter all the data you have and then continue through the process. Once the group is created click admin and look at the edit screen. Your field should be here as well, populated with the data from the registration process.
This next function adds that info to the group header info:
// Show the custom field in the group header
function show_field_in_header( ) {
echo "

My favorite color is:" . custom_field('favorite-color') . "

";
}
add_action('bp_group_header_meta' , 'show_field_in_header') ;

this hooks into the header action and adds our code to the bottom.
Now you can get the group meta using simply groups_get_groupmeta and echo it out wherever you』d like. Just be sure to pass the group_ID or it wont return anything. You can do what I did and use bp_get_group_id() as long as you know you will be in a group loop. I may come back and add more on how to access that data but if you』ve made it this far you have all the tools you』ll need!
Full Code:


<input id="favorite-color" type="text" name="favorite-color" value="" />

<?php }
// This saves the custom group meta – props to Boone for the function
// Where $plain_fields = array.. you may add additional fields, eg
//  $plain_fields = array(
//      'field-one',
//      'field-two'
//  );
function group_header_fields_save( $group_id ) {
global $bp, $wpdb;
$plain_fields = array(
'favorite-color'
);
foreach( $plain_fields as $field ) {
$key = $field;
if ( isset( $_POST[$key] ) ) {
$value = $_POST[$key];
groups_update_groupmeta( $group_id, $field, $value );
}
}
}
add_filter( 'groups_custom_group_fields_editable', 'group_header_fields_markup' );
add_action( 'groups_group_details_edited', 'group_header_fields_save' );
add_action( 'groups_created_group',  'group_header_fields_save' );

// Show the custom field in the group header
function show_field_in_header( ) {
echo "

My favorite color is:" . custom_field('favorite-color') . "

";
}
add_action('bp_group_header_meta' , 'show_field_in_header') ;
}
add_action( 'bp_include', 'bp_group_meta_init' );
/* If you have code that does not need BuddyPress to run, then add it here. */
?>

Props to Charl Kruger for his post: http://charlkruger.com/2011/12/07/getting-started-with-buddypress-group-meta