Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases

Reply
 
Thread Tools
vBulletin-WordPress Bridge Details »»
vBulletin-WordPress Bridge
Version: 1.2, by rsuplido rsuplido is offline
Developer Last Online: Mar 2013 Show Printable Version Email this Page

Version: 3.0.8 Rating:
Released: 08-15-2005 Last Update: 08-18-2005 Installs: 47
DB Changes
Code Changes Additional Files  
No support by the author.

I have been looking around for a WordPress - vBulletin plug-in and can?t seem to find one. I had time today to look at the WordPress code and tried out some things, and came up with a small hack for a bridge.

This bridge will let you use vBulletin as the main comments area for the blog entry. A copy of the intro blog entry is automatically created in a specific forum you choose, as well as a link back to the original blog entry from the forum. The blog entry will also show the total comments made.

Let me first say that I don?t have any experience in creating plug-ins for WordPress so please don?t ask me to convert this to one. If you plan to make this as an official plug-in or improve on it, please make sure to let me know so I can place a link on this article to yours.

Thanks and I hope you all enjoy it.

Note:
  • This hack will only work if your WordPress and vBulletin tables are in a single database.
  • This hack has only been tested on adding entries directly from the admin panel. It has not been tested on xmlrpc clients.
  • Use at your own risk. I will not be held liable for any loss of data nor problems that you might encounter on your site during the whole process of the mod.Backup your files and database(s) before proceeding.

Database Changes:

I have added a new column in WordPress? posts table to maintian the vBulletin thread id that will be automatically generated for the blog entry. Note that the table name prefix might be different from your WordPress table settings:
Code:
ALTER TABLE `wp_posts` ADD `vb_threadid` INT(10);
Files to Upload:

Save the following as vb3?settings.php and upload it to the Wordpress wp-includes folder:
Code:
<?php
// This just holds the vb variables
$vb_bridge = 1; // 1=on 0=off
$vb_forumid = '2'; // forum id to post copy of article
$vb_userid = '1'; // user id to use for posting the article
$vb_username = 'admin'; // name of the user id
$vb_path = 'http://www.yoursite.com/forum'; //complete url of forums
$vb_dbprefix = 'vb3_'; //vBulletin database prefix
$vb_readmessage = 'Read the full blog entry.'; //message to be used in the forum to link back to the blog entry
?>
  • $vb_forumid - is the forum id of the blog discussion forum. Usually, this is the ?News? or ?Blog? forum. I advice to to set the permission of this forum to not allow ?New Posts? but allow ?New Replies.? To get the id of the forum, on your vBulletin forums page, click on the forum that you want to assign and check the URL at the address bar. It will appear like ?..forumdisplay.php?f=x? where x is the forum id.
  • $vb_userid - is the user id you want to assign as the one who will automatically create a new thread in the forum you have chosen.To get the user id, go to your forum?s Member List and click on the member you would like to assign. The URL will appear like ?member.php?u=x? where x is the user id.
  • $vb_username - is the corresponding username of the user id. Rather than generating a new SQL query to get the username, it is better to just assign the name to this variable.
  • $vb_path - this is the actual URL of your site?s forum. Note that there is no trailing slash.
  • $vb_dbprefix - if you specified a table prefix when you installed vBulletin, enter it here.
  • $vb_dbprefix - This message will appear at the end of the vBulletin post that links back to the blog entry.

Added in v1.1: In the attached files at the right, download postfeed.php and upload it to the root folder of your vB forums (it should be in the same folder where external.php is).

Files to be Modified:

Here comes the slightly harder part. We need to modify some WordPress files. Part of the changes assume that you are using the Kubrick default theme. If you are using a different theme, change the corresponding files accordingly.

wp-includes/comment-functions.php

Replace:
Code:
function get_comments_number( $comment_id ) {
 global $wpdb, $comment_count_cache;
 $comment_id = (int) $comment_id;
 if (!isset($comment_count_cache[$comment_id]))
  $comment_count_cache[$comment_id] =  $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_id' AND comment_approved = '1'");
 
 return apply_filters('get_comments_number', $comment_count_cache[$comment_id]);
}
With:
Code:
function get_comments_number( $comment_id ) {
 global $wpdb, $comment_count_cache;
  include (ABSPATH . WPINC . '/vb3-settings.php');

 $comment_id = (int) $comment_id;
  if (!isset($comment_count_cache[$comment_id])) {
  if ($vb_bridge){
   $vb_threadid = $wpdb->get_var("SELECT vb_threadid FROM $wpdb->comments WHERE id = '$comment_id'");
   $comment_count_cache[$comment_id] = $wpdb->get_var("SELECT count(*)-1 FROM {$vb_dbprefix}post WHERE threadid = '$vb_threadid'");
  } else {
   $comment_count_cache[$comment_id] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_id' AND comment_approved = '1'");
  }
 }
 return apply_filters('get_comments_number', $comment_count_cache[$comment_id]);
}
Below:
Code:
function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
    global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb;
    global $comment_count_cache;
Add:
Code:
    include (ABSPATH . WPINC . '/vb3-settings.php');

 if ($vb_bridge){
  $vb_threadid = $post->vb_threadid;
  if ($vb_threadid == "") {
         echo $none;
         return;
  } else {
   $comment_count_cache[$id] = $wpdb->get_var("SELECT count(*)-1 FROM {$vb_dbprefix}post WHERE threadid = '$vb_threadid'");
  } 
  $number = $comment_count_cache[$id];
  echo '<a  href="'.$vb_path.'/showthread.php?t=' . $vb_threadid .'&goto=newpost">';
   comments_number($zero, $one, $more, $number);
   echo '</a>'; 
   return;
 }
Save file.

Added in v1.1: wp-includes/feed-functions.php

Replace:
Code:
function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = '') {
	$url = comments_rss($commentsrssfilename);
	echo "<a href='$url'>$link_text</a>";
}
With:
Code:
function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = '') {
	global $post;
	include_once (ABSPATH . WPINC . '/vb3-settings.php');
	if ($vb_bridge){
		$url = $vb_path . '/postfeed.php?t=' . $post->vb_threadid . '&type=rss2';
	} else {		
		$url = comments_rss($commentsrssfilename);
	}
	echo "<a href='$url'>$link_text</a>";
}
Save file.

wp-admin/post.php

Below:
Code:
require_once('admin.php');
Add:
Code:
include_once (ABSPATH . WPINC . '/vb3-settings.php');
Below:
Code:
  $result = $wpdb->query($postquery);
Modified in v1.2: Add:
Code:
	// VB Bridge Start
		if ($vb_bridge) {
			if ($post_title == "") {
				return;
			}

			$saveid = $vb_userid;
			$savename = $vb_username;

			$author_name = $wpdb->get_var("SELECT `user_login` FROM $wpdb->users WHERE `id` = '$post_author'"); 
			
			if ($author_name != ""){
				$vb_authorid = $wpdb->get_var("SELECT `userid` FROM " . $vb_dbprefix . "user WHERE `username` = '$author_name'");
				if ($vb_authorid != ""){
					$saveid = $vb_authorid;
					$savename = $author_name;
				}
			}
			$curtime = time();
			$sql = "INSERT INTO `{$vb_dbprefix}thread` 
					SET `title`='{$post_title}',`lastpost`='{$curtime}', `forumid`='{$vb_forumid}', `open`='1', `postusername`='{$savename}', `postuserid`='{$saveid}', `lastposter`='{$savename}', `dateline`='{$curtime}', `visible`='1'";
			$vbresult = $wpdb->query($sql);
			$vb_threadid = $wpdb->insert_id;
			
			if ($excerpt == ""){
				$moreflag = strpos($content,'<!--more-->');
				if ($moreflag === false) {
					$introtext = $content;
				} else {
					$introtext = substr($content, 0, $moreflag);
				} 
				$bbcontent = '[quote'.']'.strip_tags($introtext).'['.'/quote]';
			} else {
				$bbcontent = '[quote'.']'.strip_tags($excerpt).'['.'/quote]';
			}
			$bbcontent .= '[URL='.get_permalink($post_ID).']['.'b]'.$vb_readmessage.'['.'/b]['.'/URL]';				
			$sql = "INSERT INTO `{$vb_dbprefix}post` 
					SET `threadid`='{$vb_threadid}', `username`='{$savename}', `userid`='{$saveid}', `title`='{$post_title}', `pagetext`='{$bbcontent}', `ipaddress`='{$REMOTE_ADDR}', `allowsmilie`='1', `iconid`='1',`visible`='1', `dateline`='{$curtime}'";
			$vbresult = $wpdb->query($sql);
		
			$sql = "UPDATE `{$vb_dbprefix}forum` SET `threadcount`=`threadcount`+1, `lastpost`='{$curtime}', `lastposter`='{$savename}', `lastthread`='{$post_title}', `lastthreadid`='{$vb_threadid}', `lasticonid`='1' WHERE `forumid`='{$vb_forumid}' LIMIT 1";
			$vbresult = $wpdb->query($sql);
		
		  $sql = "UPDATE $wpdb->posts SET `vb_threadid`={$vb_threadid} WHERE `ID`='{$post_ID}'";
			$vbresult = $wpdb->query($sql);
		}	
	// VB Bridge End
Save file.


If you are using the Kubrick default theme, open wp-content/themes/default/comments.php

Replace contents with:
Code:
<?php // Do not delete these lines
 if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
  die ('Please do not load this page directly. Thanks!'); 

        if (!empty($post->post_password)) { // if there's a password
            if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
    ?>
    
    <p class="nocomments">This post is password protected. Enter the password to view comments.<p>
    
    <?php
    return;
            }
        }

  /* This variable is for alternating comment background */
  $oddcomment = 'alt';
?>

<!-- You can start editing here. -->
<p class="postmetadata">Discuss: <?php comments_popup_link('No Comments ?', '1 Comment ?', '% Comments ?'); ?></p>
Save File.


If you are using the Kubrick default theme, open wp-content/themes/default/single.php

Replace:
Code:
       You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(true); ?>" rel="trackback">trackback</a> from your own site.
With (note that you are adding the path of the forum):
Code:
       You can <a href="/forum/showthread.php?t=<?php echo( $post->vb_threadid ); ?>&goto=newpost">leave a response</a>, or <a href="<?php trackback_url(true); ?>" rel="trackback">trackback</a> from your own site.
Save file.


If you are using the Kubrick default theme, open wp-content/themes/default/footer.php

Replace:
Code:
  and <a href="feed:<?php bloginfo('comments_rss2_url'); ?>">Comments (RSS)</a>.
With:
Code:
  <!-- and <a href="feed:<?php bloginfo('comments_rss2_url'); ?>">Comments (RSS)</a>.-->
Save file.


Lastly, open wp-rss2.php

Replace:
Code:
  <wfw:commentRSS><?php echo comments_rss(); ?></wfw:commentRSS>
With (note that you are specifying the complete URL of the forum here):
Code:
<wfw:commentRSS>http://www.yoursite.com/forum/showthread.php?t=<?php echo $post->vb_threadid; ?></wfw:commentRSS>
Save file.

vBulletin Settings:

The RSS feed will not work if you haven't activated RSS External synidcation on your forum. To do this, on your forums admincp, go to vBulletin Options->External Data Provider and check 'Yes' on Enable RSS Syncidcation.


Final Words:

Well, that?s about it! I?m not sure how often I can visit this thread but I hope those who find success in implementing the bridge, can help those who are having problems. Again, if you have suggestions on improving the script, let me know.

Thanks and happy modding!

Live Demo: http://www.internettablettalk.com/blog/


Revision History:

v1.2 (12/7/2005):
Uses correct vB user id and user name of the blog author. This will work only if the username of the Wordpress user is exactly the same as the vB username. If not, it uses $vb_userid and $vb_username defined in the settings.

v1.1 (8/19/2005):
Revisions are based on reports by Darth Gill (see discussion). New version includes vB RSS thread parser and a bug fix on vB not displaying recently added blog entry on the forum level. Current revisions are marked in green.

Changes:
  • Added file to upload: postfeed.php (see Files to Upload section)
  • New file to modify: wp-includes/feed-functions.php
  • Fixed reported latest thread bug in wp-admin/post.php. Apply changes in green.


Screenshots:

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #162  
Old 08-03-2006, 01:35 PM
BryceW BryceW is offline
 
Join Date: Feb 2006
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For those of you who didnt see it a few pages back.

THIS WORKS FOR WP 2.0.4 and VB 3.5.4

Endquote posted an update file located here:
https://vborg.vbsupport.ru/showpost....&postcount=137

[high]* BryceW sends Endquote love. Works great [/high]
Reply With Quote
  #163  
Old 08-11-2006, 06:14 PM
YoricksRequiem YoricksRequiem is offline
 
Join Date: Jan 2004
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for everyone for the update. This is absolutely awesome.

One thing I'd like to add if it's possible - I'm using Gamerz Post-Ratings for Wordpress and I was wondering if there's a way to combine it with the vBulletin ratings, or at least a way to carry it over into the thread.

Any help is appreciated.
Reply With Quote
  #164  
Old 08-14-2006, 07:09 PM
spurstalk spurstalk is offline
 
Join Date: Sep 2004
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi, I'm new at this but I just wanted to be clear about something.

So WP and vB have to share the same database for this to work but they can be on different servers/domains?

Is it not possible at all if they are on different servers/domains and also do NOT share the same database?

Thanks in advance.
Reply With Quote
  #165  
Old 08-17-2006, 08:00 PM
RyanC RyanC is offline
 
Join Date: Jan 2005
Posts: 77
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would be more than willing to finance this project as an actual plugin... Anyone interested?
Reply With Quote
  #166  
Old 08-22-2006, 10:00 PM
Deimos Deimos is offline
 
Join Date: Oct 2002
Posts: 529
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any chance of getting this working for VB 3.6?
Reply With Quote
  #167  
Old 08-28-2006, 01:04 AM
ScruffyDeluxe's Avatar
ScruffyDeluxe ScruffyDeluxe is offline
 
Join Date: Feb 2002
Location: Merseyside
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, I've been running this for a while now, and I'm certain it's worth another beta. From the textfile:

Quote:
// Changes (+author)

* Editing an entry will also edit the first post in the thread (endquote)
* Editing an entry will not modify the timestamp of the first post in the thread (ScruffyDeluxe)
* Saving a new entry will not publish until the publish button is clicked, or if the post status checkbox is set to publish (SD)
* Any possibility of duplicate threads via changing post status hopefully squashed (SD)
* Entry quote in first post will be shown as posted by the user rather than "The Front Page" (SD)

// Bugs

* If you delete a post in WP, it doesn't get deleted in VB
* More a bug in this textfile than anything - the approximate line numbers change once you edit a file :1

// Ideas

* If you set an entry to draft status after publishing, it should moderate the thread
* Consider an overhaul to WP's comments page to show a thread view
Sorry I haven't popped in here for a while... 'issues'.
Reply With Quote
  #168  
Old 08-28-2006, 05:53 PM
Deimos Deimos is offline
 
Join Date: Oct 2002
Posts: 529
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can't seem to get it working on VB 3.6

I get this mess

Quote:
Hello world!
August 28th, 2006

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

Posted in Uncategorized | Edit |
Warning: comments_popup_link(/home/deimos/public_html/wp/wp-includes/vb3-settings.php) [function.comments-popup-link]: failed to open stream: No such file or directory in /home/deimos/public_html/wp/wp-includes/comment-functions.php on line 289

Warning: comments_popup_link(/home/deimos/public_html/wp/wp-includes/vb3-settings.php) [function.comments-popup-link]: failed to open stream: No such file or directory in /home/deimos/public_html/wp/wp-includes/comment-functions.php on line 289

Warning: comments_popup_link() [function.include]: Failed opening '/home/deimos/public_html/wp/wp-includes/vb3-settings.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/deimos/public_html/wp/wp-includes/comment-functions.php on line 289

Warning: get_comments_number(/home/deimos/public_html/wp/wp-includes/vb3-settings.php) [function.get-comments-number]: failed to open stream: No such file or directory in /home/deimos/public_html/wp/wp-includes/comment-functions.php on line 230

Warning: get_comments_number(/home/deimos/public_html/wp/wp-includes/vb3-settings.php) [function.get-comments-number]: failed to open stream: No such file or directory in /home/deimos/public_html/wp/wp-includes/comment-functions.php on line 230

Warning: get_comments_number() [function.include]: Failed opening '/home/deimos/public_html/wp/wp-includes/vb3-settings.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/deimos/public_html/wp/wp-includes/comment-functions.php on line 230
1 Comment ?
On the main WP page.
Reply With Quote
  #169  
Old 08-28-2006, 05:53 PM
Deimos Deimos is offline
 
Join Date: Oct 2002
Posts: 529
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And if I try and publish anything, I get

Quote:
Warning: wp_insert_post(/home/deimos/public_html/wp/wp-includes/vb3-settings.php) [function.wp-insert-post]: failed to open stream: No such file or directory in /home/deimos/public_html/wp/wp-includes/functions-post.php on line 10

Warning: wp_insert_post(/home/deimos/public_html/wp/wp-includes/vb3-settings.php) [function.wp-insert-post]: failed to open stream: No such file or directory in /home/deimos/public_html/wp/wp-includes/functions-post.php on line 10

Warning: wp_insert_post() [function.include]: Failed opening '/home/deimos/public_html/wp/wp-includes/vb3-settings.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/deimos/public_html/wp/wp-includes/functions-post.php on line 10

Warning: Cannot modify header information - headers already sent by (output started at /home/deimos/public_html/wp/wp-includes/functions-post.php:10) in /home/deimos/public_html/wp/wp-includes/pluggable-functions.php on line 272
Reply With Quote
  #170  
Old 08-29-2006, 05:48 AM
ScruffyDeluxe's Avatar
ScruffyDeluxe ScruffyDeluxe is offline
 
Join Date: Feb 2002
Location: Merseyside
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're missing the vb3-settings file, it seems. Although the latest file I attached has the modification steps, you'll need to check rsuplido's first post in this thread for the missing stuff (don't forget to grab postfeed.php too).

Let me know how it goes - I'm still running this on vB3.5.4 and WP 2.0.2, and it would be a nice surprise to see if it's forward-compatible
Reply With Quote
  #171  
Old 10-04-2006, 03:57 AM
Kurisu Kurisu is offline
 
Join Date: Aug 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone got this working with WP 2.0.4 and vB 3.6?
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:00 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05309 seconds
  • Memory Usage 2,345KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (19)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete