2013-06-05, 07:54 AM
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 :
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&<?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
}
?>