# Introduction Exporting/importing bbPress data presently requires some custom code that utilizes our API: http://www.wpallimport.com/documentation/developers/action-reference/. Below, we have a general guide on how to do a basic forum/topics/replies migration. Keep in mind that this is only an example and you may need to modify the approach/code to make it work exactly as desired. # Code Save the following code in the Function Editor (All Import -> Settings): ```php add_action( 'pmxi_saved_post', 'soflyy_forum_data', 10, 3 ); function soflyy_forum_data( $post_id, $xml_record, $is_update ) { global $wpdb; $import_id = wp_all_import_get_import_id(); $post_type = wp_all_import_get_import_post_type( $import_id ); switch ( $post_type ) { case 'topic': $parent_forum = get_post_meta( $post_id, '_bbp_forum_id', true ); if ( empty( $parent_forum ) ) return; $forum = $wpdb->get_var( "SELECT `post_id` FROM `" . $wpdb->prefix . "postmeta` WHERE `meta_key` = '_bbp_old_forum_id' AND `meta_value` = '" . $parent_forum . "'" ); if ( ! $forum ) return; update_post_meta( $post_id, '_bbp_topic_id', $post_id ); update_post_meta( $post_id, 'post_alter_id', $post_id ); update_post_meta( $post_id, '_bbp_last_active_time', date( "Y-m-d H:i:s", time() ) ); update_post_meta( $post_id, '_bbp_forum_id', $forum ); $args = array( 'ID' => $post_id, 'post_parent' => $forum ); wp_update_post( $args ); break; case 'reply': $old_topic_id = get_post_meta( $post_id, '_bbp_topic_id', true ); if ( empty( $old_topic_id ) ) return; $topic = $wpdb->get_var( "SELECT `post_id` FROM `" . $wpdb->prefix . "postmeta` WHERE `meta_key` = '_old_topic_id' AND `meta_value` = '" . $old_topic_id . "'" ); if ( ! $topic ) return; update_post_meta( $post_id, '_bbp_topic_id', $topic ); $forum = $wpdb->get_var( "SELECT `post_id` FROM `" . $wpdb->prefix . "postmeta` WHERE `meta_key` = '_bbp_old_forum_id' AND `meta_value` = '" . get_post_meta( $post_id, '_bbp_forum_id', true ) . "'" ); if ( ! $forum ) return; update_post_meta( $post_id, '_bbp_forum_id', $forum ); $args = array( 'ID' => $post_id, 'post_parent' => $topic ); wp_update_post( $args ); break; default: return; } } ``` # Migrate Forums Use WP All Export's "Migrate" feature to get all of the data you need, then download the "Bundle" file. Upload the bundle to a new import, but don't skip to the final step. Contine to step 3 and add a new custom field called "_bbp_old_forum_id" with the value being the {id[1]} import element. # Migrate Topics In the import, make sure the Forum ID is stored in a custom field named "_bbp_forum_id". And, add a new custom field called "_old_topic_id" with the value being the {id[1]} import element. # Migrate Replies Make sure the "_bbp_forum_id" and "_bbp_topic_id" custom fields are being imports with the {_bbp_forum_id[1]} and {_bbp_topic_id[1]} import elements. # Finishing up This may not always be necessary, but if the data on the front end of the forum looks off, you should try going to Tools -> Forums and run a repair on any of the data that looks incorrect.