MyBB Community Forums

Full Version: Integrating MyBB into your website. (Login Form)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
hmm dont think so that i'll be able to make such a plugin... im just learning basics of php so its to fast for me to write plugins...Smile
Could you please give me a code for Logout link? Thank you.
I keep geting

Warning: Cannot modify header information - headers already sent by (output started at /home/gmodfana/public_html/index1.php:6) in /home/gmodfana/public_html/forum/inc/functions.php on line 1216
You should include the files at the top before using echo or generally print functions.
Gogy Wrote:Could you please give me a code for Logout link? Thank you.

something along the lines of this will work with the latest builds

<a href="YOURFOURMLOCATION/member.php?action=logout&amp;logoutkey=<?php echo $mybb->user["logoutkey"]; ?>"><strong>Logout</strong></a>

Cheers FnT...
okay, so here's my code:

<?php

if($mybb->user['uid'])
{
echo "Hey, ".$mybb->user['username']."<br>
Thanks for logging in.";
}
else
{
echo "<form action='Forums/member.php' method='post'>
Username: <input type='text' name='username' size='15' maxlength='30' /><br />
Password: <input type='password' name='password' size='15' />
<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' /><input type='reset' class='reset' name='reset' value='Reset' /></form><br>";
}
?>

this works fine. everything is okey-koke.

however, i want a logout link when logged in, and a register link when logged out. how would i go about doing this?

i would like it included in the code itself, rather than on another page.

i've tried using <a href=""></a> links, but they won't work.

thanks
Michael83 Wrote:You can use some code like the following:
if($mybb->user['usergroup'] = "x" || $mybb->user['usergroup'] = "y" || $mybb->user['usergroup'] = "z") {
    // User can access
} else {
    // User has no permission to view the page
}
Replace x, y and z with the Group-IDs of the usergroups that are allowed to view that page.

okay, so where do i add that code first of all?

do i make a new php extension so it's like
<?php if($mybb->user['usergroup'] = "x" || $mybb->user['usergroup'] = "y" || $mybb->user['usergroup'] = "z") {
    // User can access
} else {
    // User has no permission to view the page
}; ?>

or do i add it in an existing code.

and also, how do i know what number my usergroups are?

cheers.
I will try to explain a little as you will use this code in your existing page

if($mybb->user['usergroup'] = "x" || $mybb->user['usergroup'] = "y" || $mybb->user['usergroup'] = "z") {
    // User can access
} else {
    // User has no permission to view the page
} 

look at the first part of this code if you go the bit that says

Quote:// User can access

below this make a new line and enter the code you want people to see if they belong to the group or groups mentioned above.

then the next part of the code you need to know about

Quote:// User has no permission to view the page

again create a new line and place in here a response to give or what ever to show if they do not belong to this group or groups.

as for finding the group id's or gid this one i can not see a simple way other than to open the correct table in phpmyadmin someone else might know another way but i can not seem to find a simple way??

FnT
actually, i thought of an easier way.

how do i block guests/unregistered/banned from certain pages?

in other words, how do i just allow any registered member to the page?
brootal Wrote:actually, i thought of an easier way.

how do i block guests/unregistered/banned from certain pages?

in other words, how do i just allow any registered member to the page?

Assuming you already have this from the first post:
<?php
chdir('forums'); // path to MyBB
require './global.php';
?>
You can add this:
<?php
chdir('forums'); // path to MyBB
require './global.php';

if(!$mybb->user['uid'])
{
    error_no_permission();
    // Or replace with your own "not logged in" message
}
?>
<!-- rest of your page -->
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48