MyBB Community Forums

Full Version: MyBB And Wordpress
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello Friends,

I would like to make a site as main page as wordpress and forum as mybb...

Now can anyone help me with how can I use same header and footer for both. Also If a user registers on MyBB he automatically can comment on Wordpress too.

Also how can I post my MyBB threads to wordpress?

Anyone who has done integration and would like to work on the same?

I am ready to pay for the same.

P.S : None of the plugin is working currently. (AFAIK)
Thanks
visual integration:
as you said there is a plugin for the visual integration of wordpress for MyBB - however that is not perfect.

wordpress theme content needs to be manually added to MyBB with required html & css - this is not a straight
work - requires adjustments to overcome some conflicts.

in general, wordpress uses a dynamic menu. that can not be easily added to MyBB. that is, any changes
on wordpress menu do not transfer automatically to MyBB.

users integration:
there is no single sign on system available at present. you can try this (see also this guidance & this image)
Thanx I will try these this weekend and will reply back with results.

Thanks
Actually there is a fairly simply way to generate a theme for visual integration I do this for my site. If you have a look at silvertails.net and then the forums you will see they are visually integrated.

The way I do this is fairly simple.
I have a cron or in this case I actually use a mybb task. I to goes off to a PHP file I created that grabs the output buffer of the wordpress site. For header(), sidebar() and footer()

I then do a quick clean up to remove certain aspects all in this same script, this requires some specifics.

I dump all of this out into 3 HTML files
- header
- sidebar
- footer

I have a plugin in mybb which then does a replace on <wpheader> <wpsidebar> <wpfooter>

And places the above 3 files into those locations within my mybb template.

Setup and programming time was about 1 hour and no matter what changes I make to wordpress by and large everything gets included in that I need.

I will see if I can make these a little more client facing, or user friendly and configurable with certain replaces etc and share them, or I can share them "as is" if you have some coding skills you can take the work.

With my approach even with a dynamic menu, dynamic widgets such the latest news etc on my site, they still get dragged in correctly and as is without issue as the HTML is what gets included into the mybb template.

I also added a new bit of code that regenerates the HTML when a new post is published to make sure all information is up to date
Here is the file I call from a cron to generate the HTML

<?php

require( '<your WP path>/wp-load.php' );

#### Generate the Header ###
ob_start();
get_header();
$header = ob_get_contents();
ob_end_clean();

$header = preg_replace('/<!*DOCTYPE(.*?)<\/head>/si', "",$header);
$header = preg_replace('/<body(.*?)>/si', "",$header);
$header = preg_replace('/<!--[ ]*Start[ ]*Advertisement[ ]*1[ ]*-->(.*?)<!--[ ]*end[ ]*advertisement[ ]*1[ ]*-->/si', '{myadvertisements[zone_1]}', $header);
//<!-- Start Advertisement 1 -->
//'/<!--[ ]*START[ ]*NO[ ]*PRINT[ ]*-->(.*?)<!--[ ]*END[ ]*NO[ ]*PRINT[ ]*-->/si'

$patterns[0] = '/class="/';
$patterns[1] = '/id="/';
$patterns[2] = "/class='/";
$replacements = array();
$replacements[2] = 'class="wp';
$replacements[1] = 'id="wp';
$replacements[0] = "class='wp";

$header = preg_replace($patterns, $replacements, $header);


$header = preg_replace('/class="wpcat-item cat/', 'class="wpcat-item wpcat', $header);

$header .= '<div id="wpcontent">';
file_put_contents("<whatever path you want>/header.html", $header);
############################


#### Generate the sidebar #####

ob_start();
dynamic_sidebar('right-sidebar');
$sidebar = ob_get_contents();
ob_end_clean();

$patterns[0] = '/class="/';
$patterns[1] = '/id="/';
$patterns[2] = "/class='/";
$replacements = array();
$replacements[2] = 'class="wp';
$replacements[1] = 'id="wp';
$replacements[0] = "class='wp";
$sidebar = preg_replace($patterns, $replacements, $sidebar);
$sidebar = str_replace('href="#', 'href="#wp', $sidebar);

$sidebar = preg_replace('/<!--[ ]*Start[ ]*Advertisement[ ]*5[ ]*-->(.*?)<!--[ ]*end[ ]*advertisement[ ]*5[ ]*-->/si', '{myadvertisements[zone_5]}', $sidebar);
$sidebar = preg_replace('/<!--[ ]*Start[ ]*Advertisement[ ]*6[ ]*-->(.*?)<!--[ ]*end[ ]*advertisement[ ]*6[ ]*-->/si', '{myadvertisements[zone_6]}', $sidebar);
$sidebar = preg_replace('/<!--[ ]*Start[ ]*Advertisement[ ]*4[ ]*-->(.*?)<!--[ ]*end[ ]*advertisement[ ]*4[ ]*-->/si', '{myadvertisements[zone_4]}', $sidebar);
$sidebar = preg_replace('/<!--[ ]*Start[ ]*Advertisement[ ]*9[ ]*-->(.*?)<!--[ ]*end[ ]*advertisement[ ]*9[ ]*-->/si', '{myadvertisements[zone_9]}', $sidebar);

file_put_contents("<whatever path you want>/sidebar.html", $sidebar);

Please note the myadvertisement stuff isn't going to be relevant to any of you unless you have some custom code I have. Basically I have more code that includes myadvertisement adverts into my wordpress site so I can manage the adverts from a single location and they stay dynamic rather than being static.

So either null that out or come up with similar code, its too custom for me to release at this point.

Just call this either when you make a change in wordpress (easy code to write) or call it say once an hour or twice a day depending on how often you make theme and menu changes. Or alternatively call it directly.

This will generate you a header footer and sidebar code, you may need to add in some code to re-add any require JS though.

Then you can either use the dynamic header and footer plugin or write your own, I will try to drop the code in here late when I have a chance

Oh also What it does is change all of the wordpress CSS to be prepended with "wp-" so I then have a CSS file which I have included into my mybb theme, which is essentially and exact copy of my WP theme with a few things removed, simply because I wanted a different font on forums etc.

So you will need to do the same. you then need to change all of the CSS to be wp-whatever

then you should be good to go. You can automate that as well but I have lost the code that I used to do that
^ Thank You @ Dannymh