Функции Bbpress в другом плагине
Я новичок в сообществе. Я надеюсь следовать правилам сообщества, чтобы опубликовать вопрос.
Мы идем на консультацию, я начинаю проект elcual состоит из ежедневной публикации информации (информация разбита по темам, каждая тема имеет несколько глав). Для этого используйте wordpress, bbpress и плагин импорта WP All Import. Плагин импорта позволяет использовать функции WordPress.
Я могу импортировать темы и ответить без проблем. Это работает отлично, однако уведомления подписчиков импортированной темы и форума не могут заставить их работать. Я попытался встроить bbpress functions.php и функции bbp_notify_forum_subscribeers и bbp_notify_topic_subscribeers, но мне не удалось. Другая функция, которую я также хотел использовать после завершения импорта, - это восстановление отношений bbp_register_default_repair_tools, но выдает ошибку.
Я создал этот код, который импортирует тему / ответ и связывает их с их родственником, но он не решает вышеупомянутые проблемы.
Этот код работает в WP All Import functions.php
Правильно ли я использую и использую функции bbpress (отправка электронной почты подписчику и восстановление отношений)?
<?php
include "/bbpress/includes/common/functions.php";
//pmxi_saved_post : This hook is called after WP All Import creates or updates a post. It is generally used if you
add_action( 'pmxi_saved_post', 'soflyy_forum_data', 10, 3 );
include "/bbpress/includes/admin/tools.php";
//pmxi_after_xml_import : This hook is called after WP All Import finishes an import.
add_action('pmxi_after_xml_import', 'bbp_register_default_repair_tools', 10, 1);
function soflyy_forum_data( $post_id, $xml_record, $is_update ) {
$exped = array('1','3','5','7','9','11');//ID's IMPORT FILE TOPIC
$actualiz = array('2','4','6','8','10','12');//ID's IMPORT FILE REPLY
$import_id = ( isset( $_GET['id'] ) ? $_GET['id'] : ( isset( $_GET['import_id'] ) ? $_GET['import_id'] : 'new' ) );
if ( in_array($import_id,$exped) ) {
//----Update imported TOPIC data---//
$parent_forum = get_post_meta( $post_id, '_bbp_forum_id', true );
if ( $parent_forum != 0 ) {
$args = array(
'ID' => $post_id,
'post_parent' => $parent_forum
);
wp_update_post( $args );
update_post_meta( $post_id, '_bbp_topic_id', $post_id );
update_post_meta( $post_id, 'post_alter_id', $post_id );
update_post_meta( $post_id, '_bbp_last_active_time', date( "Y-m-d H:i:s", time() ) );
//-------//
//>>>Send notification to subscriber<<<<///
bbp_notify_forum_subscribers ( $post_id, $parent_forum, $anonymous_data = false, 2 );
//>>>-----<<<<///
}
} elseif ( in_array($import_id,$actualiz) ) {
//----Update imported REPLY data---//
$old_topic_id = get_post_meta( $post_id, '_bbp_topic_id', true );
$post = get_posts( array(
'post_type' => 'topic',
'meta_key' => '_old_topic_id',
'meta_value' => $old_topic_id
) );
if ( $post ) {
$new_topic_id = $post[0]->ID;
$args = array(
'ID' => $post_id,
'post_parent' => $new_topic_id
);
wp_update_post( $args );
update_post_meta( $post_id, '_bbp_topic_id', $new_topic_id );
update_post_meta( $post_id, '_edit_last', 1 );
//-------//
//>>>Send notification to subscriber<<<<///
$id_forum = get_post_meta( $post_id, '_bbp_forum_id', true );
bbp_notify_topic_subscribers ( $post_id, $new_topic_id, $id_forum,$anonymous_data = false, 2 );
//>>>----<<<<///
}
}
}
function bbp_register_default_repair_tools() {
// Topic meta
bbp_register_repair_tool( array(
'id' => 'bbp-sync-topic-meta',
'description' => __( 'Recalculate parent topic for each reply', 'bbpress' ),
'callback' => 'bbp_admin_repair_topic_meta',
'priority' => 5,
'overhead' => esc_html__( 'Low', 'bbpress' ),
'components' => array( bbp_get_reply_post_type() )
) );
// Forum meta
bbp_register_repair_tool( array(
'id' => 'bbp-sync-forum-meta',
'description' => __( 'Recalculate parent forum for each topic and reply', 'bbpress' ),
'callback' => 'bbp_admin_repair_forum_meta',
'priority' => 10,
'overhead' => esc_html__( 'Low', 'bbpress' ),
'components' => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() )
) );
// Forum visibility
bbp_register_repair_tool( array(
'id' => 'bbp-sync-forum-visibility',
'description' => __( 'Recalculate private and hidden forums', 'bbpress' ),
'callback' => 'bbp_admin_repair_forum_visibility',
'priority' => 15,
'overhead' => esc_html__( 'Low', 'bbpress' ),
'components' => array( bbp_get_forum_post_type() )
) );
// Sync all topics in all forums
bbp_register_repair_tool( array(
'id' => 'bbp-sync-all-topics-forums',
'description' => __( 'Recalculate last activity in each topic and forum', 'bbpress' ),
'callback' => 'bbp_admin_repair_freshness',
'priority' => 20,
'overhead' => esc_html__( 'High', 'bbpress' ),
'components' => array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() )
) );
// Sync all sticky topics in all forums
bbp_register_repair_tool( array(
'id' => 'bbp-sync-all-topics-sticky',
'description' => __( 'Recalculate sticky relationship of each topic', 'bbpress' ),
'callback' => 'bbp_admin_repair_sticky',
'priority' => 25,
'overhead' => esc_html__( 'Low', 'bbpress' ),
'components' => array( bbp_get_topic_post_type() )
) );
// Sync all hierarchical reply positions
bbp_register_repair_tool( array(
'id' => 'bbp-sync-all-reply-positions',
'description' => __( 'Recalculate the position of each reply', 'bbpress' ),
'callback' => 'bbp_admin_repair_reply_menu_order',
'priority' => 30,
'overhead' => esc_html__( 'High', 'bbpress' ),
'components' => array( bbp_get_reply_post_type() )
) );
// Sync all BuddyPress group forum relationships
bbp_register_repair_tool( array(
'id' => 'bbp-group-forums',
'description' => __( 'Repair BuddyPress Group Forum relationships', 'bbpress' ),
'callback' => 'bbp_admin_repair_group_forum_relationship',
'priority' => 35,
'overhead' => esc_html__( 'Low', 'bbpress' ),
'components' => array( bbp_get_forum_post_type() )
) );
// Update closed topic counts
bbp_register_repair_tool( array(
'id' => 'bbp-sync-closed-topics',
'description' => __( 'Repair closed topics', 'bbpress' ),
'callback' => 'bbp_admin_repair_closed_topics',
'priority' => 40,
'overhead' => esc_html__( 'Medium', 'bbpress' ),
'components' => array( bbp_get_topic_post_type() )
) );
// Count topics
bbp_register_repair_tool( array(
'id' => 'bbp-forum-topics',
'description' => __( 'Count topics in each forum', 'bbpress' ),
'callback' => 'bbp_admin_repair_forum_topic_count',
'priority' => 45,
'overhead' => esc_html__( 'Medium', 'bbpress' ),
'components' => array( bbp_get_forum_post_type(), bbp_get_topic_post_type() )
) );
// Count forum replies
bbp_register_repair_tool( array(
'id' => 'bbp-forum-replies',
'description' => __( 'Count replies in each forum', 'bbpress' ),
'callback' => 'bbp_admin_repair_forum_reply_count',
'priority' => 50,
'overhead' => esc_html__( 'High', 'bbpress' ),
'components' => array( bbp_get_forum_post_type(), bbp_get_reply_post_type() )
) );
// Count topic replies
bbp_register_repair_tool( array(
'id' => 'bbp-topic-replies',
'description' => __( 'Count replies in each topic', 'bbpress' ),
'callback' => 'bbp_admin_repair_topic_reply_count',
'priority' => 55,
'overhead' => esc_html__( 'High', 'bbpress' ),
'components' => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() )
) );
// Count topic voices
bbp_register_repair_tool( array(
'id' => 'bbp-topic-voices',
'description' => __( 'Count voices in each topic', 'bbpress' ),
'callback' => 'bbp_admin_repair_topic_voice_count',
'priority' => 60,
'overhead' => esc_html__( 'Medium', 'bbpress' ),
'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
) );
// Count non-published replies to each topic
bbp_register_repair_tool( array(
'id' => 'bbp-topic-hidden-replies',
'description' => __( 'Count pending, spammed, & trashed replies in each topic', 'bbpress' ),
'callback' => 'bbp_admin_repair_topic_hidden_reply_count',
'priority' => 65,
'overhead' => esc_html__( 'High', 'bbpress' ),
'components' => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() )
) );
// Recount topics for each user
bbp_register_repair_tool( array(
'id' => 'bbp-user-topics',
'description' => __( 'Recount topics for each user', 'bbpress' ),
'callback' => 'bbp_admin_repair_user_topic_count',
'priority' => 70,
'overhead' => esc_html__( 'Medium', 'bbpress' ),
'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
) );
// Recount topics for each user
bbp_register_repair_tool( array(
'id' => 'bbp-user-replies',
'description' => __( 'Recount replies for each user', 'bbpress' ),
'callback' => 'bbp_admin_repair_user_reply_count',
'priority' => 75,
'overhead' => esc_html__( 'Medium', 'bbpress' ),
'components' => array( bbp_get_reply_post_type(), bbp_get_user_rewrite_id() )
) );
// Remove unpublished topics from user favorites
bbp_register_repair_tool( array(
'id' => 'bbp-user-favorites',
'description' => __( 'Remove unpublished topics from user favorites', 'bbpress' ),
'callback' => 'bbp_admin_repair_user_favorites',
'priority' => 80,
'overhead' => esc_html__( 'Medium', 'bbpress' ),
'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
) );
// Remove unpublished topics from user subscriptions
bbp_register_repair_tool( array(
'id' => 'bbp-user-topic-subscriptions',
'description' => __( 'Remove unpublished topics from user subscriptions', 'bbpress' ),
'callback' => 'bbp_admin_repair_user_topic_subscriptions',
'priority' => 85,
'overhead' => esc_html__( 'Medium', 'bbpress' ),
'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
) );
// Remove unpublished forums from user subscriptions
bbp_register_repair_tool( array(
'id' => 'bbp-user-forum-subscriptions',
'description' => __( 'Remove unpublished forums from user subscriptions', 'bbpress' ),
'callback' => 'bbp_admin_repair_user_forum_subscriptions',
'priority' => 90,
'overhead' => esc_html__( 'Medium', 'bbpress' ),
'components' => array( bbp_get_forum_post_type(), bbp_get_user_rewrite_id() )
) );
// Remove unpublished forums from user subscriptions
bbp_register_repair_tool( array(
'id' => 'bbp-user-role-map',
'description' => __( 'Remap existing users to default forum roles', 'bbpress' ),
'callback' => 'bbp_admin_repair_user_roles',
'priority' => 95,
'overhead' => esc_html__( 'Low', 'bbpress' ),
'components' => array( bbp_get_user_rewrite_id() )
) );
}
?>
Я хотел бы знать, что я делаю неправильно. С уважением...