Finally got Wordpress and SMF integrated

Started by wing, December 28, 2009, 11:10:54 AM

Previous topic - Next topic

wing

Hey all!

I use to have a site where when someone posted a comment in wordpress it put it SMF instead, I had a few people ask me for the code but it was a major hack of wordpress 1.1 which is obsolete.

I have done a similar thing now in wordpress 2.8.4 (works in 2.9) as well.  I did not need to integrate users.  Basically I just moved my comments out of wordpress and into the forum.  We have chosen not to show the forum posts in our wordpress articles to keep it more professional looking although it is easily do-able as well as putting a comment box into wordpress.

Here is the site: http://www.canadiandriver.com 

Most of the articles have this enabled, I just turned it on and any posts older than 7 days have comments disabled so being x-mas there isn't much.  But the Mustang post on the front page shows how this is done quite well.

The code is written fairly specifically for my needs but I think I could share the code with minor tweaks if anyone is interested.  I made it a plug-in for wordpress which makes it fairly easy to integrate.


kanderson88


wing

#2
I have attached the plugin, just stick it into your plugin folder.

You will need to do 1 other thing to get it to work after you enable it.

open single.php in your wordpress theme and add the following at the top.
require_once("/path/to/forum/SSI.php");
global $boardID;
$boardID = '19571' ; // 19571 is the board ID of your SMF board you wish posts to appear in.

You need to add this to your single.php where you want your comments link to appear.

do_action('comment_form', $post->ID

I have created multiple actions that chose different boards based on the category of the wordpress post.  If you simply want to always use the same one you can declare it in Forum_AddWPPost right in the plugin.

Also you should create a user in the forum to post under and declare it in the same function as above called posterInfo

Orstio


wing

Thanks.

I forgot the most important thing!

You need to add this to your single.php

do_action('comment_form', $post->ID);

Where you want your comments to show up!

wing

I updated the file, I had hard coded my URL link to my forum in the code.  I changed to get your hostname based on your server.  Hopefully that works for all.

If someone is familiar with making an admin menu for wordpress I wouldn't mind making one so that you can configure the 3 or 4 things required right within wordpress in order to make the plugin seamless to install and get working.


ianus

Greetings!

Interesting idea. Like it.

Short Question.
Do you have to write the first post (on SMF) with the Read more... link inside manually or is it created automatically?

Sakae

Sounds pretty good to me. But it works only for SMF 1.1 or can I emulate this to SMF 2.0 RC2?
http://www.tigrelog.com.br
l: simple p: machines

wing

Quote from: ianus on January 11, 2010, 08:59:00 AM
Greetings!

Interesting idea. Like it.

Short Question.
Do you have to write the first post (on SMF) with the Read more... link inside manually or is it created automatically?

Everything this created automatically.

I used SMF 2.0 briefly it should work for SMF 2.0 as well.  Once 2.0 goes final I will be switching to 2.0.

HackSrc

When I try to use this I get the following error.

Fatal error: Call to undefined function db_query() in /var/www/web11/web/wp-content/plugins/custom_comments/custom_comments.php  on line 153

Any ideas?

Word Press Version 2.9.2
SMF Version 1.1.11

yermaninja

#10
my assumption is that the forum has to be read and write by anonymous right?

well, I couldn't get it to work. It's not posting to my forum.

my forum is on a subdomain would that matter?

wing

Quote from: HackSrc on April 01, 2010, 03:44:23 PM
When I try to use this I get the following error.

Fatal error: Call to undefined function db_query() in /var/www/web11/web/wp-content/plugins/custom_comments/custom_comments.php  on line 153

Any ideas?

Word Press Version 2.9.2
SMF Version 1.1.11

Did you include SSI.php as outlined above?

tragidy

Any confirmed working with WP 3.0.X if so a demo link please?
Open source Matters, the GNU GPL License is one of the most valuable text ever created by mankind.
Support all open source projects when possible as their concepts are paving the future. ~ tragidy

wing

I don't see why this wouldn't work unless they changed the Database considerably.

tinoest

Thanks for the script!

It almost suited my requirements although I did have to make quite a few changes to various parts of it.

Gamogo

#15
Quote from: wingDid you include SSI.php as outlined above?

Hmm, I'm encountering the same error. I have the require statements applied also.

I believe this has got something to do with SM2's changes to functions. 'db_query' no longer exists and it is now $smfFunc['db_query'], however when I use this, the script complains the query is not a string. Odd.

Edit: Discovered this:

http://www.simplemachines.org/community/index.php?topic=275952.0

"Make sure that you have $smcFunc in globals (and SSI.php is included)."

Will give this a try tomorrow :D

Gamogo

Ok, I got the function working by applying $smcFunc in the global option, but the lpugin still fails in SM2.

I now receive an SQL syntax error on line 157. Line 157 looks like this:


"      $res = $smcFunc['db_query']("
          SELECT ID_MEMBER, realName, emailAddress
           FROM {$db_prefix}members
     WHERE $where LIMIT 1", __FILE__, __LINE__) ;"

Suggesting the SQL statement in SM2 has been reworked somewhat. I'm a  bit lost now :/

Anyone using SM2 been able to get this to work as expected?


Kindred

column names have changed in smf 2. Please look at your database to find that actual names for those columns.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Not only the column names but the entire DB handling. That individual query would be rewritten thus:

$res = $smcFunc['db_query']('', '
          SELECT id_member, real_name, email_address
           FROM {db_prefix}members
     WHERE ' . $where . ' LIMIT 1');

sdkid

Does the SMF install still log the appropriate IP address, or does the redirect from WordPress mess that up?

Advertisement: