Action starting before it's done!
-
Hi people, i’m trying to create a new bbPress forum when new post is saved…I made out this code but the only thing i get it’s an infinite loop. The strange is that the loop starts not when i save a post, but first, when i go in “All posts” or in “new Posts”. What’s the problem please?
This is the code
<?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); } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Action starting before it's done!’ is closed to new replies.