MyBB Community Forums

Full Version: MyBB Integrator not working correctly
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm using the MyBB Integration Class from the MyBB Mod Site: (http://mods.mybb.com/view-resource/mybb-...tion-class)

I'm having an issue, I emailed this to the developer. I thought I would post here to see if anyone could help me though.

Quote:Hey Dave.

I found your MyBB Integration Class on the MyBB Mods site. I know it hasn’t been updated since 2010 but I’m assuming it still works? I tried to use it, and logging in was fine however isLoggedIn(), logout(), and other functions failed to work. I’m assuming it has to do with my cookie domain/path. Here’s my MyBB info:

Domain: .stellarrecharge.com
Path: /community/

My MyBB installation is on /community/, but my site is on /beta/. Here’s my code, is there something I’m doing wrong? I just get a blank page when I login and nothing displays. My code is attached. Any help is appreciated!

The file is attached. Thanks in advance for any help!
try Path: /
...and then it works for the whole domain.
That currently works for me.
Hello JakeA,

If i understood you right, your code returns a blank page, I suggest you to add a few global variables infront of your included files, try adding these right after your define('IN_MYBB', NULL);

Like this:
<?php
global $mybb, $db, $cache, $plugins, $lang, $config;
define('IN_MYBB', NULL);
require_once '../community/global.php';

You must always use global variables if you are using your mybb code within another core system, e.g a CMS.
Okay..that made the function "isLoggedIn()" work, however "logout()" still fails to work, but I'm assuming I did that wrong.

@bowkilled -

I have all those, except the global one at top is in a variable, $myBBI
(2012-07-09, 05:54 AM)JakeA Wrote: [ -> ]Okay..that made the function "isLoggedIn()" work, however "logout()" still fails to work, but I'm assuming I did that wrong.

@bowkilled -

I have all those, except the global one at top is in a variable, $myBBI

Your logout function probably doesn't work because you aren't defining the logoutkey which mybb uses to logout a user, try this within your code:

<?php
//Lets proceed to the logout link
echo '<a link="http://www.domain.tld/?logoutkey=', $MyBBI->mybb->user['logoutkey'], '">Logout</a>';

//Build the logout function
if ($_GET['logoutkey']){
$MyBBI->logout();
}
?>
I should have been more specific:
When dealing with different directories, setting the cookie path to '/', will make your MyBB cookie work properly.
Wasn't trying to answer about the blank pages.

#
@bowkilled Thanks for the complete answer; Will probably need this soon.

(2012-07-09, 05:44 AM)bowkilled Wrote: [ -> ]Hello JakeA,

If i understood you right, your code returns a blank page, I suggest you to add a few global variables infront of your included files, try adding these right after your define('IN_MYBB', NULL);

Like this:
<?php
global $mybb, $db, $cache, $plugins, $lang, $config;
define('IN_MYBB', NULL);
require_once '../community/global.php';

You must always use global variables if you are using your mybb code within another core system, e.g a CMS.

FYI:
He did already here:
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config); 

At least that's the way the 'MyBBIntegrator' was supposed to be used; It hasn't been updated in a long time.
Thank you, that worked! Do you know how to make it redirect after logging in and logging out? Currently it just returns to the form, and the you are logged in page. Forcing me to refresh the page to see the form, or the you are logged in page again.
(2012-07-09, 07:03 AM)JakeA Wrote: [ -> ]Thank you, that worked! Do you know how to make it redirect after logging in and logging out? Currently it just returns to the form, and the you are logged in page. Forcing me to refresh the page to see the form, or the you are logged in page again.

That's weird, are you saying that you're able to view the "logged in" content? If so, then I'm pretty sure you need to check so that you have the correct cookie path.

If you want to redirect to another page after the logout, just insert a header location function after the $MyBBI->logout();

header('Location: http://www.yourdomain.com/');
Sorry, I typed that weirdly. I solved it. Works well. Thank you both so so so much. Rep+ for both Smile Smile
(2012-07-09, 07:39 AM)JakeA Wrote: [ -> ]Sorry, I typed that weirdly. I solved it. Works well. Thank you both so so so much. Rep+ for both Smile Smile

No problem, always glad to help others.
Pages: 1 2