MyBB Community Forums

Full Version: Myy login form in wordpress
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hey my mybb dir is : www.haifafans.net/fanclub/
wordpress will be here : www.haifafans.net
i use this code :
<?php
chdir('fanclub'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>
<?php

if($mybb->user['uid'])
{
// The user is logged in, say Hi
echo "Hey, $mybbuser[username].<br>
Thanks for logging in.";
}
else
{
// The user is not logged in, Display the form
echo "<form action='fanclub/member.php' method='post'>
Username: <input type='text' name='username' size='25' maxlength='30' /><br />
Password: <input type='password' name='password' size='25' />
<input type='hidden' name='action' value='do_login'>
<input type='hidden' name='url' value='index.php' />
<input type='submit' class='submit' name='submit' value='Login' /></form><br>";
}
?>

i put it as Widget in wordpress ( html )
[Image: image-6D06_4A37F927.jpg]

and when i save i check the site , the login form look like this :
[Image: image-1107_4A37F927.jpg]

whats wrong ?


i test the code in normal php page its working
http://www.haifafans.net/login.php
i sucess login , but when i go back to http://www.haifafans.net/login.php

still ask me to put username and pass , i can't see this :
Hey, $mybbuser[username]. Thanks for logging in
"Your Javascript/HTML/Flash embed code or others". Widgets don't support PHP.

You can:
  1. Show an iframe (bad, bad, bad)
  2. Get form/welcomeblock via AJAX (Good)
  3. Don't use Widgets (Good good good)
mmmmmmmm so how can i have form/wekcomeblock via AJAX ?
Quote:i put it as Widget in wordpress ( html )

Do you think it works with html extension? Toungue
It's best just to hard code that code into your sidebar template preferrably above the widget code so taht it's doesn't get removed when you add in a widget.

Also I don't think this will work. I put in similar code into my wordpress install and I got an error relating to two functions of the same name. I could be wrong, but I'm pretty sure including global.php is the cause but required for the login function to work. It could be plugin related as I do have a lot of plugins but you might run into the same problem as I did.
Assuming you're running 2.8 (which it looks like you are), go to Appearance -> Editor.

Header.php
Add this at the very beginning:
<?php
chdir('fanclub'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>

Sidebar.php
Before it says:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>

Add this:
<?php

if($mybb->user['uid'])
{
// The user is logged in, say Hi
echo "Hey, $mybbuser[username].<br>
Thanks for logging in.";
}
else
{
// The user is not logged in, Display the form
echo "<form action='fanclub/member.php' method='post'>
Username: <input type='text' name='username' size='25' maxlength='30' /><br />
Password: <input type='password' name='password' size='25' />
<input type='hidden' name='action' value='do_login'>
<input type='hidden' name='url' value='index.php' />
<input type='submit' class='submit' name='submit' value='Login' /></form><br>";
}
?>