Version: 1.00, by KuraFire
Developer Last Online: Nov 2023
Version: 2.2.x
Rating:
Released: 05-07-2002
Last Update: Never
Installs: 75
No support by the author.
Oh my Kura, you're releasing small, simple hacks every day now, huh? What's this one about?
Rest assured, after this one I don't have anything to release for a while (only stuff that has no purpose outside my own board).
Well, this hack. What it does is 'merge' the Register and User CP buttons. If a viewer is a guest or just not logged in, the link will display a Register button (or text link, whatever you want). If the viewer IS logged in, and therefore a member, it will display the User CP button instead.
Add ABOVE that, the following code:
Make sure to remove the space between {imagesfolder and }!!
PHP Code:
// guest/member register/usercp hack
if($bbuserinfo['userid'] != 0) {
$reg_ucp = "<a href=\"usercp.php?s=$session[sessionhash]\">".
"<img src=\"{imagesfolder }/usercp.gif\" ".
"alt=\"Here you can view your subscribed threads, work with private messages and edit your profile and preferences\" ".
"border=\"0\"></a>";
}else{
$reg_ucp = "<a href=\"register.php?s=$session[sessionhash]&action=signup\">".
"<img src=\"{imagesfolder }/register.gif\" ".
"alt=\"Registration is free!\" border=\"0\"></a>";
}
Step 2: save your global.php and go to Edit your Header template (Styles > modify > fonts/colors > Header). Now, put
$reg_ucp
somewhere in your Header, where you want the UserCP / Register button to appear. Make sure to remove the 'hardcoded' buttons that are already in there, of course.
Save, and you're done.
Note that if you aren't using the default vB templates and graphics (which is 99% likely? ) you'll have to adjust the code above to suit your needs. If you don't use images, just remove the image part there and replace it with text links.
Extra feature that you can use with this hack: add Guest-only banners or something alike. In other words, only guests will see the banner (which could say something like "Want to get rid of this annoying banner? Then sign up now!") and users who are logged in won't see anything.
To do so, use something like this:
PHP Code:
// guest/member register/usercp hack
if($bbuserinfo['userid'] != 0) {
$reg_ucp = "blablabla usercp";
$banner = "";
}else{
$reg_ucp = "blablabla register";
$banner = "<img src=\"{imagesfolder }/banner.gif\" />".
"<br />Want to get rid of this banner? Then sign up now!";
}
Now place $banner in your header or footer wherever you want, and only guests will see it.
Enjoy!
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Has anyone had any problems with this on version 2.3.0? I just upgraded my board and it's ignoring the code - no error, but not links.
/// nevermind - it works with 2.3.0 once one remembers to upload the file.
04-12-03 at 06:32 PM Rose said this in Post #65 Kura - a useful hack never goes out of style.
Thank you
Splitfyre, it's just a switch between the Register and the User CP link/button, that's all. You don't really need imagination to see what it looks like, you know
Kura or littlebit can ya guys help me a bit here, the hack works great, but one problem... my navigational buttons on my header uses rollover images... how would i implement this? i tried copying some of the code from my header into this hack and tried adding the necessary " to it, but its not showing up the images at all... here's the code...
PHP Code:
if($bbuserinfo['userid'] != 0) {
$reg_ucp = "<a href=\"usercp.php?s=$session[sessionhash]\">".
"<a onmouseover=\"changeImages('image1', 'image1a')\" onmouseout=\"changeImages('image1', 'image1b')\" img name=\"image1\" src=\"{imagesfolder}/usercp.gif\" ".
"width=\"50\" ".
"height=\"25\" ".
"alt=\"Here you can view your subscribed threads, work with private messages and edit your profile and preferences\" border=\"0\"></a>";
}else{
$reg_ucp = "<a href=\"register.php?s=$session[sessionhash]&action=signup\">".
"<a onmouseover=\"changeImages('image2', 'image2a')\" onmouseout=\"changeImages('image2', 'image2b')\" ".
"img name=\"image2\" ".
"src=\"{imagesfolder}/register.gif\" ".
"width=\"50\" ".
"height=\"25\" ".
"alt=\"Register an account\" ".
"border=\"0\"></a>";