BuddyPress bbPress每个成员唯一的线程



我希望在一个地方讨论每个用户。是否有可能为每个用户自动分配一个唯一的bbPress线程,并在BuddyPress配置文件中放置一个链接到该线程?

我目前的尝试是将以下代码添加到functions.php:

function automatic_user_forum( $user_id ) {
if( !$user_id ) return false;
$post = array(
‘post_title’ => ‘My forum’,
‘post_content’ => ‘This is a forum.’,
‘post_name’ => ‘my-forum’,
‘post_status’ => ‘publish’,
‘post_type’ => ‘forum’,
);
$post_id = wp_insert_post($post);
}
add_action( ‘bp_core_activated_user’, ‘automatic_user_forum’ );

然而,它不工作,网站崩溃。任何帮助吗?

或者我尝试以下不会崩溃,但也不创建任何论坛。什么错了吗?

<?php
function bbp_insert_girl_forum() {
$forum_data = array(
        'post_parent'    => 0, // forum ID
        'post_content'   => 'Nullam est felis, tempor luctus consequat a, aliquam ut dolor. Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.',
        'post_title'     => 'Test Forum: Loads of Topics for topic Pagination',
    );
    if(function_exists('bbp_insert_forum')) {
        $forum_id = bbp_insert_forum( $forum_data );
    }else {
        print "insert forum not defined";
            }
        $topic_data = array(
            'post_parent'    => $forum_id, // forum ID
            'post_content'   => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.',
            'post_title'     => 'Gravida facilisis eleifend',
        );
        if(function_exists('bbp_insert_topic')) {
            $topic_id = bbp_insert_topic( $topic_data );
        }
                else {
                print "insert topic not defined";
                    }
}
add_action( ‘bp_core_activated_user’, ‘bbp_insert_girl_forum’ );
?>
function bbp_insert_girl_forum() {
$forum_data = array(
    'post_parent'    => 0, // forum ID
    'post_content'   => 'Nullam ...',
    'post_title'     => 'Test Forum',
);
if(function_exists('bbp_insert_forum')) {
    $forum_id = bbp_insert_forum( $forum_data );
}
}
add_action( 'bp_core_activated_user', 'bbp_insert_girl_forum' );

相关内容

  • 没有找到相关文章

最新更新