bp_activity_new_comment_notification (intcomment_id美元intcommenter_id美元数组美元的参数数组()

当活动项目收到评论时,发送电子邮件和BP通知。

描述

参数

comment_id美元

int(必需)评论id。

commenter_id美元

int(必需)发表评论的用户ID。

美元的参数

数组(可选)bp_activity_new_comment ()

默认值:数组()

文件:bp-activity / bp-activity-functions.php

function bp_activity_new_comment_notification($comment_id = 0, $commenter_id = 0, $params = array()) {$original_activity = new BP_Activity_Activity($params['activity_id']);$poster_name = bp_core_get_user_displayname($commenter_id);$thread_link = bp_activity_get_permalink($params['activity_id']);Remove_filter ('bp_get_activity_content_body', 'convert_smilies');Remove_filter ('bp_get_activity_content_body', 'wpautop');Remove_filter ('bp_get_activity_content_body', 'bp_activity_truncate_entry', 5);/**这个过滤器记录在bp-activity/bp-activity-template.php */ $content = apply_filters_ref_array('bp_get_activity_content_body', array($params['content'], &$original_activity));Add_filter ('bp_get_activity_content_body', 'convert_smilies');Add_filter ('bp_get_activity_content_body', 'wpautop');Add_filter ('bp_get_activity_content_body', 'bp_activity_truncate_entry', 5); if ( $original_activity->user_id != $commenter_id ) { // Send an email if the user hasn't opted-out. if ( 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) { $unsubscribe_args = array( 'user_id' => $original_activity->user_id, 'notification_type' => 'activity-comment', ); $args = array( 'tokens' => array( 'comment.id' => $comment_id, 'commenter.id' => $commenter_id, 'usermessage' => wp_strip_all_tags( $content ), 'original_activity.user_id' => $original_activity->user_id, 'poster.name' => $poster_name, 'thread.url' => esc_url( $thread_link ), 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), ), ); bp_send_email( 'activity-comment', $original_activity->user_id, $args ); } /** * Fires at the point that notifications should be sent for activity comments. * * @since BuddyPress 2.6.0 * * @param BP_Activity_Activity $original_activity The original activity. * @param int $comment_id ID for the newly received comment. * @param int $commenter_id ID of the user who made the comment. * @param array $params Arguments used with the original activity comment. */ do_action( 'bp_activity_sent_reply_to_update_notification', $original_activity, $comment_id, $commenter_id, $params ); } /* * If this is a reply to another comment, send an email notification to the * author of the immediate parent comment. */ if ( empty( $params['parent_id'] ) || ( $params['activity_id'] == $params['parent_id'] ) ) { return; } $parent_comment = new BP_Activity_Activity( $params['parent_id'] ); if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id ) { // Send an email if the user hasn't opted-out. if ( 'no' != bp_get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) { $unsubscribe_args = array( 'user_id' => $parent_comment->user_id, 'notification_type' => 'activity-comment-author', ); $args = array( 'tokens' => array( 'comment.id' => $comment_id, 'commenter.id' => $commenter_id, 'usermessage' => wp_strip_all_tags( $content ), 'parent-comment-user.id' => $parent_comment->user_id, 'poster.name' => $poster_name, 'thread.url' => esc_url( $thread_link ), 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), ), ); bp_send_email( 'activity-comment-author', $parent_comment->user_id, $args ); } /** * Fires at the point that notifications should be sent for comments on activity replies. * * @since BuddyPress 2.6.0 * * @param BP_Activity_Activity $parent_comment The parent activity. * @param int $comment_id ID for the newly received comment. * @param int $commenter_id ID of the user who made the comment. * @param array $params Arguments used with the original activity comment. */ do_action( 'bp_activity_sent_reply_to_reply_notification', $parent_comment, $comment_id, $commenter_id, $params ); } }

更新日志

更新日志
版本 描述
BuddyPress 2.5.0更新使用新的电子邮件api。 BuddyPress 2.5.0更新使用新的电子邮件api。
BuddyPress 1.2.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队