自定义电子邮件

自定义电子邮件

Codex Home → Emails → Custom Emails
Custom Emails

BuddyPress only includes emails for BuddyPress core functionality. Blog posting is not part of BuddyPress, but it could be an integral part of your community. Let』s look at an example to send an email to a blog post author when a user comments on their post.
Note: This requires the BP Email API which is only available in BP 2.5.0+.
Email Post Type
BuddyPress emails are a Custom Post Type so adding emails is similar to creating posts and pages. The function below will programmatically add a post and add the correct taxonomy. Taxonomies are used to connect the email with the correct Situation or action that will trigger the sending of the email. Hook your email creation to bp_core_install_emails – this insures that it will be created if you need to reset emails using the 「Re-install emails」 tool in the admin tools. You can call the function directly as part of activating your plugin via register_activation_hook.
function codex15766_custom_email_message() {

// Do not create if it already exists and is not in the trash
$post_exists = post_exists( '[{{{site.name}}}] New post comment.' );

if ( $post_exists != 0 && get_post_status( $post_exists ) == 'publish' )
return;

// Create post object
$my_post = array(
'post_title' => __( '[{{{site.name}}}] New post comment.', 'buddypress' ),
'post_content' => __( '{{commenter.name}} commented on your blog post.', 'buddypress' ), // HTML email content.
'post_excerpt' => __( '{{commenter.name}} commented on your blog post.', 'buddypress' ), // Plain text email content.
'post_status' => 'publish',
'post_type' => bp_get_email_post_type() // this is the post type for emails
);

// Insert the email post into the database
$post_id = wp_insert_post( $my_post );

if ( $post_id ) {
// add our email to the taxonomy term 'post_received_comment'
// Email is a custom post type, therefore use wp_set_object_terms

$tt_ids = wp_set_object_terms( $post_id, 'post_received_comment', bp_get_email_tax_type() );
foreach ( $tt_ids as $tt_id ) {
$term = get_term_by( 'term_taxonomy_id', (int) $tt_id, bp_get_email_tax_type() );
wp_update_term( (int) $term->term_id, bp_get_email_tax_type(), array(
'description' => 'A member comments on a posts',
) );
}
}

}
add_action( 'bp_core_install_emails', 'codex15766_custom_email_message' );

Send Email
For the next step, hook an action to wp_insert_comment to get the comment data and then send the post author an email. In this function, you create the tokens to parse out in the email before sending. The tokens array can be anything but you usually want to keep it personal to the recipient.
bp_send_email() takes three arguments:

the taxonomy term you set up in the the CPT above
the recipients user ID
the array of tokens to parse in the title, body and excerpt of the email

function codex15766_comment_inserted( $comment_id, $comment_object ) {

if ( $comment_object ) {
// get the post data
$post = get_post( $comment_object->comment_post_ID );
// add tokens to parse in email
$args = array(
'tokens' => array(
'site.name' => get_bloginfo( 'name' ),
'commenter.name' => $comment_object->comment_author,
),
);
// send args and user ID to receive email
bp_send_email( 'post_received_comment', (int) $post->post_author, $args );
}
}
add_action( 'wp_insert_comment','codex15766_comment_inserted', 99, 2 );

设置 → 删除帐户

设置 → 删除帐户

Codex Home → Member Guide → Settings → Delete Account
Settings → Delete Account

This is where you can delete your account in the site, if account deletion was enabled by the Site Admin. Note that deleting your account will delete all the content you have created in the site. Those will be completely irrecoverable.

⇐ Previous: Settings → Profile Visibility
⇐ Back to Member Guide

活动 → 好友

活动 → 好友

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

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

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

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

将自定义选项卡添加到群组目录

将自定义选项卡添加到群组目录

Codex Home → Add Custom Tab to Groups Directory
Add Custom Tab to Groups Directory

This is an example of how to add a custom tab to the Groups Directory.
And call a custom template when that tab is clicked.
The same approach can be used to add a custom tab to the Members Directory.
The tab will be called Custom and it will load a template called groups-custom.php.
?12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879// add Custom tab on Groups Pagefunction asdf_groups_custom_tab() {     if ( bp_is_current_action( 'custom' ) )         return;     $button_args = array(        'id'         => 'groups-custom',        'component'  => 'groups',        'link_text'  => __( 'Custom', 'buddypress' ),        'link_title' => __( 'Custom', 'buddypress' ),        'link_class' => 'group-custom no-ajax',        'link_href'  => trailingslashit( bp_get_groups_directory_permalink() . 'custom' ),        'wrapper'    => false,        'block_self' => false,    );           ?>    

  •      0,            'post_title'     => 'Groups Custom',            'post_author'    => 0,            'post_date'      => 0,            'post_content'   => '',            'post_type'      => 'page',            'post_status'    => 'publish',            'is_page'        => true,            'comment_status' => 'closed'        ) );    }     public function create_content() {        return bp_buffer_template_part( 'groups/groups-custom', null, false );    } }
    This example assumes that the groups-custom.php template is in your theme at this location:
    .../wp-content/themes/your-theme/buddypress/groups/groups-custom.php
    If you want to load the template from a plugin, you need to register the location of the template:
    ?12345678910111213// add path to plugin templatesfunction asdf_register_template_location() {    return dirname( __FILE__ ) . '/templates/';}  function asdf_template_start() {     if( function_exists( 'bp_register_template_stack' ) )        bp_register_template_stack( 'asdf_register_template_location' ); }add_action( 'bp_init', 'asdf_template_start' );
    More info about using BP Theme Compat in plugins.

    WordPress 版本兼容性

    WordPress 版本兼容性

    Codex Home → Getting Started → WordPress version compatibility
    WordPress version compatibility

    BuddyPress shines brightest when run on the newest available version of WordPress – we optimize for the latest and greatest. For this reason, the BuddyPress team strongly recommends that all WordPress installations be kept up to date. However, we strive to maintain support for a number of legacy WordPress versions – generally, four or five major versions.
    Near the beginning of each development cycle, we reassess BuddyPress』s minimum required WP version. Our rough guidelines are as follows:

    If a WordPress version became obsolete over a year ago, it』s a candidate for removal. See https://wordpress.org/news/category/releases/ for a list of WP release dates.
    If a WordPress version』s use slips below 5% of all WP installations, it』s a strong candidate for removal. See https://wordpress.org/about/stats/ for information about WordPress version usage.

    What do we mean when we say that BP 「supports」 a given version of WordPress? Roughly:

    BuddyPress should run error-free (ie, without fatal errors or PHP notices) on the WP version.
    If a new version of BP includes a feature that requires a very recent version of WordPress, the feature should be gracefully disabled on earlier WP versions.
    The WP version will be included in our automated testing builds.

    By extension: When we 「drop support」 for a version of WordPress, it means we stop including it in our builds, stop answering support questions related to that specific WP version, and stop putting function_exists() checks (and the like) targeting that version when building new BP features. Dropping support does not mean that we will actively try to break older versions of WP

    ⇐ Getting Started

    活动 → 小组

    活动 → 小组

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

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

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

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

    群组 → 邀请

    群组 → 邀请

    Codex Home → Member Guide → Groups → Invitations
    Groups → Invitations

    This page shows a list of Groups where you have been invited to by a friend who is a member of the group. You have the option to accept or reject the invitation.

    ⇒ Next: Groups → Create
    ⇐ Previous: Groups → Memberships
    ⇐ Back to Member Guide

    个人资料 → 编辑

    个人资料 → 编辑

    Codex Home → Member Guide → Profile → Edit
    Profile → Edit

    Based on how many Profile Field Groups were set up by the Site Administrator, you』ll only need to fill a page or, if it was set up like in the example in the previous page, four panels.
    Profile → Edit screen for the First Group of Profile Fields: Base

    Profile → Edit screen for the Second Group of Profile Fields: Testing It

    Profile → Edit screen for the Third Group of Profile Fields: Single Fields

    Profile → Edit screen for the Fourth Group of Profile Fields: Multi Fields

    ⇒ Next: Profile → Change Profile Photo
    ⇐ Previous: Profile → View
    ⇐ Back to Member Guide