Skip to content

Instantly share code, notes, and snippets.

@stefanich
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanich/4f8f7b436b87287f44bf to your computer and use it in GitHub Desktop.
Save stefanich/4f8f7b436b87287f44bf to your computer and use it in GitHub Desktop.
callback_method for Vanilla import using ReplyTo plugin
<?php
// Added to converter.php
private function callback_oldid( $field ) {
if ( 0 == $field ) {
return 0;
} else {
$row = $this->wpdb->get_row($this->wpdb->prepare('SELECT post_id, meta_value FROM wp_postmeta WHERE meta_key = "_bbp_post_id" AND meta_value = "%s" LIMIT 1', $field));
if( !is_null( $row ) ) {
return $row->post_id;
} else {
return 0;
}
}
}
//Added to Vanilla converter file
// Make sure it is after the mapping that creates new post
$this->field_map[] = array(
'from_tablename' => 'Comment',
'from_fieldname' => 'ParentCommentID',
'to_type' => 'reply',
'to_fieldname' => '_bbp_reply_to',
'callback_method' => 'callback_oldid'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment