Hello,
How would I go about adding ONLY the following to my main site?
If NOT registered or logged in, it would display this:
Hello, Guest! > Login | Register <
If LOGGED IN, it would display this:
Welcome back, {username}! > View New Posts <
And that's it.
I'm not looking to add the entire Welcome Panel. I just want the things specified above.
If anyone can help or provide some insight, it would be much appreciated.
Thanks!
Can't imagine this is 'too' hard for all you MyBB-savvy people out there.
Any help would be great!
Deals with cookies. Store a cookie with the name of the person, etc. When the user logs off, expire the cookie.
delete everything from the welcomeback_user and stuff to just what you want...
So you wouldn't want them to be able to access UserCP or be able to logout? Your request doesn't make sense!
Crystatic:
If I knew how to do it, I wouldn't have posted this thread.
turpentine:
I want to add this stuff to my main site -- not edit the forum's welcomeback_user template.
judel:
Ok, how about this:
If LOGGED IN: "Welcome back, {username}! (User CP — Log Out) | View New Posts
If NOT logged in: "Hello, Guest! (Login — Register) | Why Register?"
The 'Why Register?' part would link to a main content page on the site and describe the benefits to registering.
Hope this makes more sense and someone is able to help.
Thanks!
<?php
include "./forums/inc/config.php";
require "./forums/inc/inc/db_mysql.php";
$db = new databaseEngine;
define('TABLE_PREFIX', $config['table_prefix']);
$db->connect($config['hostname'], $config['username'], $config['password']);
$db->select_db($config['database']);
// Create session for this user
$logon = explode("_", $_COOKIE['mybbuser'], 2);
if($_COOKIE['mybbuser'])
{
$query = $db->simple_select(TABLE_PREFIX."users", "*", "uid='".intval($logon[0])."' AND loginkey='".$db->escape_string($logon[1])."'", array('limit' => '1'));
}
if($query && $db->num_rows($query) > 0)
{
$user = $db->fetch_array($query);
$userbit = "Welcome back, {$user['username']}! (User CP — Log Out) | View New Posts";
}
else
{
$userbit = 'Hello, Guest! (Login — Register) | Why Register?';
}
?>
Just put that in your sites php file at the top, and echo $userbit wherever you want it to show up. You'll have to put in the links in the variables though, and remember to change the /forums/ to your forum path.
Thanks a lot for the help, Tikitiki!
I have run into a problem, though...
I get this error:
Fatal error: Cannot instantiate non-existent class: timer in /home/blahblah/public_html/forum/inc/db_mysql.php on line 120
And I tried replacing the include and require paths to the full URL just to see what would happen, and I got this error instead:
Fatal error: Cannot instantiate non-existent class: databaseengine in
http://www.myurl.com/ on line 4
It's better to just use
require "./forums/inc/init.php";
and remove:
$db = new databaseEngine;
define('TABLE_PREFIX', $config['table_prefix']);
$db->connect($config['hostname'], $config['username'], $config['password']);
$db->select_db($config['database']);
Then you could use the $mybb->user variable as well.
Hey Crakter. Thanks for helping.
I did what you said, and am now getting this error:
Direct initialization of this file is not allowed.
Please make sure IN_MYBB is defined.
What do I do to fix this?
Also, how would Tikitiki's code be changed to use the $mybb->user variable?