如果您检查“publish\\u post”操作的函数。
function bp_post_published_notification( $post_id, $post ) {
$author_id = $post->post_author; /* Post author ID. */
if ( bp_is_active( \'notifications\' ) ) {
bp_notifications_add_notification( array(
\'user_id\' => $author_id,
\'item_id\' => $post_id,
\'component_name\' => \'custom\',
\'component_action\' => \'custom_action\',
\'date_notified\' => bp_core_current_time(),
\'is_new\' => 1,
) );
}
}
add_action( \'publish_post\', \'bp_post_published_notification\', 99, 2 );
请注意,您只向Post Author发送通知。您需要将“bp\\u notifications\\u add\\u notification”函数中的“user\\u id”参数更改为所需的用户id。
这是Codex Documentation 对于bp_notifications_add_notification 作用
<小时>EDIT :
更新函数如下:
function bp_post_published_notification( $post_id, $post ) {
// $author_id = $post->post_author;
$active_users = bp_core_get_users( array("per_page"=>-1));
foreach ( $active_users[\'users\'] as $user ) {
if ( bp_is_active( \'notifications\' ) ) {
bp_notifications_add_notification( array(
\'user_id\' => $user->ID,
\'item_id\' => $post_id,
\'component_name\' => \'custom\',
\'component_action\' => \'custom_action\',
\'date_notified\' => bp_core_current_time(),
\'is_new\' => 1,
) );
}
}
}
add_action( \'publish_post\', \'bp_post_published_notification\', 99, 2 );
Click here 有关的更多详细信息
\'bp_core_get_users\' 作用