Skip to:
Content
Pages
Categories
Search
Top
Bottom

Manually inserting a topic


  • s1r0n
    Participant

    @s1r0n

    I need some help. I am trying to manually insert a topic into a forum. I’m doing from a different blog on the network however so I’m assuming I can’t use BBPRESSS functions to do so. anyway the code I have so far looks like this

     switch_to_blog(LP_SCHOOL_BLOG);
    
        	// Forum
    	$reply_data = array(
    		'post_parent'    => 0, // topic ID
    		'post_status'    => 'publish',
    		'post_type'      => 'topic',
    		'post_author'    => $current_user->ID,
    		'post_password'  => '',
    		'post_content'   => $post_content,
    		'post_title'     => "New Resource: " . $post->post_title,
    		'menu_order'     => 0,
    		'comment_status' => 'closed'
    	);
    
    	// Insert reply
    	$reply_id   = wp_insert_post( $reply_data );
    
            update_post_meta( $reply_id, '_bbp_author_ip' , get_user_ip() );
            update_post_meta( $reply_id, '_bbp_forum_id' , 2231 );
            update_post_meta( $reply_id, '_bbp_topic_id' , 0);
    //        update_post_meta( $reply_id, '_bbp_topic_id', (int) $topic_id );
            restore_current_blog();

    This code is correctly posting a topic. I can see the topic at the back end, and it looks exactly like any other topic, from the back end, but it is not appearing in the forum listing at the front end.Is there some additional bit of meta data that I have to insert? to get it to show up at the front end?

    TIA

    m

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar