2013-05-18 61 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); 

} 

?> 

回答