print_r( get_post_meta( XXX ) );
functions.php
file or anywhere you execute custom functions:/**
* Run this function once to set the Thread ID to
* the post meta so XFtoWP can refresh the thread later.
*/
function convert_vb_to_xfwp() {
$thread = array();
$post_id = 99832;
$thread_id = 337;
//$thread_id = get_post_meta( get_the_ID(), 'vbconnectorthreadid', true );
$thread['comments']['thread_id'] = $thread_id;
$thread['comments']['last_update'] = time();
update_post_meta( $post_id, 'xfwp', $thread );
}
add_action( 'init', 'convert_vb_to_xfwp' );
$post_id
variable to the test post/page in WordPress and change $thread_id
to the thread ID in XenForo. The hidden $thread_id
line is what should access the vB connector thread ID on all posts, which you should also test.To confirm, did you paste this line with the function? I see it was cut off in my last post.Hey Alex! I tried this, but even though I can see the PHP execute, it is not storing the thread id into postmeta.
add_action( 'init', 'convert_vb_to_xfwp' );
If you select "Connect a thread" from here do you see the thread ID in the text field that appears? I just tested my function again and the thread ID linked to my post, so I'm a little surprised this hasn't worked for you.Yes, I had that line in the function. I did not see either of those things afterward. I do not believe caching is the issue, as I did see the PHP execute on the page.
The edit post page showed the following still:
View attachment 3801
Excellent, allow me a little time to play around with a looped version and we can try a crude but effective method to move your old thread ID on all your blog posts. 😀I see what happened. I was using my web-based file editor instead of SSH into the server. The code ended up outside the <?PHP ?> on functions.php so even though I saw the code on the page it wasn't actually executing.
I retried this morning and caught that error, now this method worked!
/**
* Run this function once to set the Thread ID to
* the post meta so XFtoWP can refresh the thread later.
*/
function convert_vb_to_xfwp() {
$thread = array();
$posts = new WP_Query( array(
'post_type' => 'post',
'fields' => 'ids',
'posts_per_page' => -1
) );
if ( $posts->have_posts() )
while( $posts->have_posts() ) {
$posts->the_post();
$post_id = get_the_ID();
$vb_thread_id = get_post_meta( $post_id, 'vbconnectorthreadid', true );
if ( empty( $vb_thread_id ) )
continue;
$thread['comments']['thread_id'] = $vb_thread_id;
$thread['comments']['last_update'] = time();
update_post_meta( $post_id, 'xfwp', $thread );
}
wp_reset_query();
}
add_action( 'init', 'convert_vb_to_xfwp' );
I wonder if I am correctly accessing the vB thread ID in this line. Since I don't have the data I wasn't able to test it, but this is the most important line:Hey @Alex,
For some reason, this didn't work. No data was added to the post_meta that I could find. We take nightly backups and have quite a lot of server overhead, so I don't have too many concerns about data or performance issues.
$vb_thread_id = get_post_meta( $post_id, 'vbconnectorthreadid', true );
posts_per_page
parameter to the query so it ensures to query ALL posts. I had thought the parameter was set to unlimited by default but it is instead set to the number of posts your site is setup to show per blog page.That's GREAT news!Looks like that got it linked now! Waiting for the comments to show up on the article now, but it shows in the Edit Post widget now, and clicking the "Start the discussion" link takes me to the XF thread. I think this is a caching issue, I'm purging caches in a few places to see if they show up. I'll update you after they show on each post.
thread_id
and last_update
are saved the threads will fall into XFtoWP's normal syncing routines. Once a visitor goes to any page it will trigger the comments to refresh on the same page load so over time your pages will populate with comments as they are visited.This is just fantastic news and a big milestone for our plugin. Thank you for working with me and for getting your hands a little dirty with some custom functions!For anyone else who might make this same migration as we did, the vB plugin was called SolidCoding Wordpress-vBulletin Connector or sometimes SCvBConnector. After this short troubleshooting with Alex, this was absolutely a cakewalk to re-connect a few thousand connected threads!