MyBB Community Forums

Full Version: Website Integration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,

I am wanting to integrate the user system of my forum to my web site. I tried using the contents from this post: http://community.mybboard.net/thread-6190-page-1.html

This works great, until Smarty comes into the picture. I am using Smarty template engine. I made that script a function.

Now, when I try viewing the site, I get this error:

Quote:Fatal error: Call to a member function simple_select() on a non-object in /home/justinw/public_html/forums/inc/class_datacache.php on line 72

Alright, now, when I remove the part of the script that requires global.php, I will receive no error but the script will not work.

I understand this has nothing to do with MyBB (at least I don't think so). But, if I cannot get it to work, I'll have to change forum software.


Can anybody help me?
You said the code works before you made it a function, is that correct?
If "Yes", why not just make the code into an include file?
Nevermind! It's the error regardless.

Now it's just functions.php, which has:
<?php
//////////////////////////////
// Functions.php
//////////////////////////////

function userbar() {

	define("IN_MYBB", 1);
	require 'forums/global.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='forums/member.php' method='post'>
	Username: <input type='text' name='username' size='25' maxlength='30' />  
	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>";
	}

}

?>

And, then index.php which calls the function.
Are you still getting the error in your first post and I am not sure what I you are asking in your second post?
Okay, I have done some more testing. I get the same error as the first post on all of these methods.

The script cannot be in a function, if it's in a function it will not work. If it cannot be in a function, then how can I make it work in Smarty?
Can you post what your code looks like on line 72?
I get the same error when I add the following code in my index.php
<?php 
chdir('./forum/'); // path to MyBB
define("IN_MYBB", 1);
require "./global.php";
if($mybb->user['uid'])
{
echo yes;
}
else
{
echo no;
} ?>

I'm using joomla and I think that there's a conflict with mybb when I add this code.
Is there another way to check if an user is logged in or not?