2013-05-18 97 views
0

我試圖創建一個新的bbPress論壇時,新的職位被保存...我做了這個代碼,但唯一的事情,我得到它是一個無限循環。奇怪的是,循環開始時不是當我保存一篇文章,但首先,當我進入「所有職位」或「新職位」。請問有什麼問題?Wordpress動作開始之前開始

這是

<?php 

add_action('save_post', 'register_ForumCustom'); 

function register_ForumCustom($post_id){ 

    $post = get_post($post_id); 
    // Create post object 
    $my_new_post = array(
     'post_title' => 'Forum di'.$post->post_title, 
     'post_content' => '', 
     'post_status' => 'publish', 
     'post_author' => 1, 
     'post_type' => 'forum' 
    ); 

    // Insert the post into the database 
    $new_forum_id = wp_insert_post($my_new_post); 

    //OK, maybe is here that the loop starts, but i know that the problem is because there is another "save_post". I can solve this, but i don't understand the other problem! 

    update_post_meta($post_id, "forum_id", $new_forum_id); 

} 

?> 

回答