0
我想討論一個地方的每個用戶。是否有可能爲每個用戶自動分配一個獨特的bbPress線程,並有一個鏈接到該線程放置在BuddyPress配置文件?BuddyPress bbPress每個成員的唯一線程
我現在嘗試下面的代碼添加到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’);
?>