MyBB Community Forums

Full Version: How to have a "Your Profile"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello every one. I am going to show you how to import a "Your Profile" button. First off you will need to import all the stuff like if you where to make a login system with it.
This should go at the complete top of the website.
<?php
chdir('forums/'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>
Next we want to add this where we want the login system to be.
if($mybb->user['uid'])
{
// The user is logged in, say Hi
echo "Hey, " . $mybb->user['username'] . "!";
?>
<?php echo"<a href='forums/member.php?action=profile&uid=" . $mybb->user['uid']; echo "'>";?> You're Profile
<?php
}
else
{
// The user is not logged in, Display the form
echo "<form action='forums/member.php' method='post'>
Username: <br><input type='text' name='username' size='25' maxlength='30' /><br />
Password: <br><input type='password' name='password' size='25' /><br>
<input type='hidden' name='action' value='do_login'>
<br>
<input type='hidden' name='url' value='/' />
<input type='submit' class='submit' name='submit' value='Login' /></form><br>";
}
?>
Now doing a bit of investigation with the forums i noticed the the profile link is classified using the UID. UID is User ID. You will have 1-how many users have registered on your website. You *being the admin and first person to sign up on the website* should be 1. But we can't just do something like:
<?php echo"<a href='forums/member.php?action=profile&uid=1";?> You're Profile ?>
This would bring you only to your profile. We want it to bring it to the user's profile. If wanted, we can come up with a idea, or create a bootstrap. These can be complicated just to get to a users profile. So I sat there and though. How can I do this without taking to much time?
Then I remembered about the . *this is AND in PHP* so I sat there and it took me about 10 minutes because well, i'm not good with PHP.
I came up with a end result of:
<?php echo"<a href='forums/member.php?action=profile&uid=" . $mybb->user['uid']; echo "'>";?> You're Profile
I felt really stupid not thinking of this. but I decided to make this to save you guys time. Thanks Big Grin

The end product:

<?php
chdir('forums/'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>

if($mybb->user['uid'])
{
// The user is logged in, say Hi
echo "Hey, " . $mybb->user['username'] . "!";
?>
<br>
<?php echo"<a href='forums/member.php?action=profile&uid=" . $mybb->user['uid']; echo "'>";?> You're Profile<br>
<a href='forums/member.php?action=logout&logoutkey=5b55442536a4d92a97ff3d98ce49825b'>Logout</a>
<?php
}
else
{
// The user is not logged in, Display the form
echo "<form action='forums/member.php' method='post'>
Username: <br><input type='text' name='username' size='25' maxlength='30' /><br />
Password: <br><input type='password' name='password' size='25' /><br>
<input type='hidden' name='action' value='do_login'>
<br>
<input type='hidden' name='url' value='/' />
<input type='submit' class='submit' name='submit' value='Login' /></form><br>";
}
?>
</div>
good work - but where do we use it and how to use it
we already have profile link available in the header block and there is also a welcome block for members.

<a href='forums/member.php?action=logout&logoutkey=5b55442536a4d92a97ff3d98ce49825b'>Logout</a>
should be
<a href="{$mybb->settings['bburl']}/member.php?action=logout&amp;logoutkey={$mybb->user['logoutkey']}">Logout</a>)
(2013-05-06, 03:31 AM).m. Wrote: [ -> ]good work - but where do we use it and how to use it
we already have profile link available in the header block and there is also a welcome block for members.

<a href='forums/member.php?action=logout&logoutkey=5b55442536a4d92a97ff3d98ce49825b'>Logout</a>
should be
<a href="{$mybb->settings['bburl']}/member.php?action=logout&amp;logoutkey={$mybb->user['logoutkey']}">Logout</a>)

I can work on a better post. I will try to fix it sometime within the next 24 hours. I have school this morning and its 3 am. Sad I can't sleep lol.

But this was meant to be used on the sidebar or header. Different places eould need tweaking. This is meant to be on a side page also. Such as "Home" "About Us"