MyBB Community Forums

Full Version: integrate Welcome box throughout the Wordpress site?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have my main wordpress site on www.mainsite.com
and Forums installed at www.mainsite.com/forum/

i want to display the Welcome Box i.e. the login and logout buttons, on throughout my wordpress site.

How to do it?

When I inserted the following code in index.php, it appears only on Homepage, but when i insert in the headers.php, it starts giving me errors :

<?php
    global $rootpath;
    $rootpath = "/home/freekipp/public_html/";

    $forumpath = $rootpath . "forum/";
    
    chdir($forumpath);
    define("IN_MYBB", 1);
    require($forumpath . "global.php");
    require_once MYBB_ROOT."inc/class_parser.php";
    $parser = new postParser;
    chdir($rootpath);
?>

<?php
    // Display if the user is logged in
    if ($mybb->user['uid']) {
?>
Welcome <a href="/forum/member.php?action=profile&uid=<?php echo $mybb->user["uid"]; ?>"><?php echo $mybb->user["username"]; ?></a>
<br />
<a href="/forum/member.php?action=logout&amp;<?php echo "logoutkey={$mybb->user['logoutkey']}"; ?>">Logout</a>
<?php
    } else { // If the user is not logged in then display the login form
?>
<form action="/forum/member.php" method="post">
    <input type="hidden" name="my_post_key" value="<?php echo $mybb->post_code; ?>" />
    Username: <input type="text" name="username" size="20" maxlength="30" /><br />
    Password: <input type="password" name="password" size="20" /><br />
    <input type="hidden" name="action" value="do_login" />
    <input type="hidden" name="url" value="/index.php" />
    <input type="submit" name="submit" value="Login" />
</form>
<?php
    }
?>
what is the error you are getting and can we have your site URL
(2013-06-05, 08:06 AM).m. Wrote: [ -> ]what is the error you are getting and can we have your site URL

it gives the following error:

Fatal error: Call to a member function read() on a non-object in /home/freekipp/public_html/forum/inc/class_plugins.php on line 36
^ try defining $cache as global
(2013-06-05, 08:58 AM).m. Wrote: [ -> ]^ try defining $cache as global

How should i do that? where should i paste this code?
^ try adding to global $rootpath; like this --> global $rootpath, $cache;
(2013-06-05, 09:14 AM).m. Wrote: [ -> ]^ try adding to global $rootpath; like this --> global $rootpath, $cache;

Thanks done that, you are a genius, the login box now comes on all the pages, But my homepage(of wordpress site) doesnt shows, it gives me an error:

Fatal error: Cannot redeclare class phptpl_templates in /home/freekipp/public_html/forum/inc/plugins/phptpl.php(71) : eval()'d code on line 26
^ try changing require($forumpath . "global.php"); to require_once($forumpath . "global.php");