+ Reply to Thread
Results 1 to 3 of 3
Like Tree2Likes
  • 1 Post By denzil
  • 1 Post By callumh98412

Thread: Integrate MyBB forums with your website

  1. #1
    denzil is offline x10 Sophmore denzil is an unknown quantity at this point
    Join Date
    Jan 2011
    Location
    South Africa
    Posts
    134

    Integrate MyBB forums with your website

    Hi! I recently had the need to integrate my myBB forums with my website (such as logins and other user info). I found this to be a short and elegant solution. I tested this in mybb version 1.6.1, and it worked on Chrome and IE 8. I believe it works in FF and Opera too. This is a php solution by the way.

    Firstly, add this in your index page (make sure you add it before any other includes. It's a good idea to make it the first lines of code on your page):

    <?php
    chdir("mybb/");
    define("IN_MYBB", 1);
    include("./global.php");
    chdir("../");
    ?>
    Note, the directory change has to point to your forum's directory. My example forums are in the "mybb" directory in my public_html.

    I also checked my adminCP on my forums. Go configuration, settings, general configuration.
    Here you can check the following:
    *Check that Cooke Domain is set to your correct domain, for example .myexample.x10.mx
    *Cookie Path: /
    *Cookie Prefix: I read to leave this blank.

    Now you can access your user data from any page on your website:
    $mybb->user['username'], will give you the username, of course.

    Here are some other details you could access:
    $mybb->user['uid'];
    $mybb->user['remember'];
    $mybb->usergroup['canviewprofiles'];
    $mybb->user['usergroup'];
    $mybb->user['language'];
    $mybb->usergroup['cansendemail'];
    $mybb->user['email'];
    $mybb->user['logoutkey'];
    $mybb->user['signature'];
    $mybb->user['avatar'];
    $mybb->user['pmnotice'];
    $mybb->user['notepad'];
    $mybb->user['totalpms'];
    $mybb->user['birthdayprivacy'];
    $mybb->user['hideemail'];
    $mybb->user['usertitle'];
    $mybb->user['birthday'];
    $mybb->user['website'];
    $mybb->user['msn'];
    $mybb->user['yahoo'];
    $mybb->user['icq'];
    $mybb->user['aim'];

    I believe these are all up to date and still work!

    Here is an example of a login form that will display if the user is not logged in:
    <?php
    if(!$mybb->user['uid'])
    {
    echo "<form action='mybb/member.php' method='post'>";
    echo "<input type='hidden' name='action' value='do_login' />";
    echo "<input type='hidden' name='url' value='../index.php' />";
    echo "Username: <input type='text' name='username' maxlength='30' /><br />";
    echo "Password: <input type='password' name='password' /><br />";
    echo "<input type='submit' name='submit' value='Login' />";
    echo "</form>";
    }
    ?>
    Note: you should add the global.php includes as described as well in any file that you wish to access the $mybb object.

    You can make it static of course, but I'm not going to do that here. Hope someone finds this useful!
    Last edited by denzil; 01-22-2011 at 06:29 AM.
    dinomirt96 likes this.

  2. #2
    callumh98412 is offline x10Hosting Member callumh98412 is an unknown quantity at this point
    Join Date
    Jan 2011
    Posts
    15

    Re: Integrate MyBB forums with your website

    What's the code for when the user is logged in? Private message it to me
    Last edited by callumh98412; 09-18-2011 at 05:05 AM.
    karimirt47 likes this.

  3. #3
    nirajkum is offline x10 Sophmore nirajkum is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    161

    Re: Integrate MyBB forums with your website

    thanks it was really useful

+ Reply to Thread

Similar Threads

  1. RSS to integrate into my website.
    By indians in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 09-04-2010, 04:29 AM
  2. Integrate blog to website?
    By the_site in forum Off Topic
    Replies: 0
    Last Post: 03-08-2010, 05:01 AM
  3. MyBB:Blog (a blogging application for MyBB)
    By xadrieth in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 10-02-2009, 05:44 PM
  4. cantt see the forums in my website
    By nadeems in forum Scripts & 3rd Party Apps
    Replies: 11
    Last Post: 06-30-2008, 02:44 PM
  5. Embeding Forums into Website?
    By moose in forum Scripts & 3rd Party Apps
    Replies: 12
    Last Post: 03-26-2006, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers