vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Register link for guests, User CP link (or button) for members. (https://vborg.vbsupport.ru/showthread.php?t=38416)

KuraFire 05-07-2002 10:00 PM

Register link for guests, User CP link (or button) for members.
 
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.

Click here for an example
(where `register` is will be `user cp` when you're logged in).

I mean, why have a Register button for members available, and a User CP button available for guests? :)

Exactly, that makes no sense, therefore, this hack. :)


Instructions

Step 1: Open your global.php and find this line:

PHP Code:

// ###################### Start templates ####################### 

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!

KuraFire 05-08-2002 10:49 AM

No screenshots cos this is so simple your imagination should suffice. :p

Sorry about the side-scrolling btw, I always work with wrapping on :/

(oh and please note that "blablabla ...." should, of course, be replaced with what's in there, above. :p)

Admin 05-08-2002 11:03 AM

I edited your post to make it not scroll. :)

KuraFire 05-08-2002 11:13 AM

Thanks, but it still scrolled on reso 1152x864 (and below) so I edited it even more. :)

(you beat me to it, I was still working on adding the hack to the DB before editing it myself to make it thinner, bah! :p :D)

NTLDR 05-08-2002 12:10 PM

Nice hack KuraFire, shame I already added this to by board a few days ago ;)

None the less good job.

Velocd 05-08-2002 01:42 PM

Good hack, but I have a suggestion.. Why not replace the "new thread" and "new reply" buttons with a button that says "register to post" or "register". Then make it link to a page where you can choose to register, or log in (since some people just forget to log in, and log in when creating a new thread).

Takara 05-08-2002 06:05 PM

Works nicely, thanks alot ^_^

*continues to add small subtle hacks to her board* :bunny:

Takara 05-08-2002 06:09 PM

Uh oh. you should note that in the php code box it doesnt escape the " in "Registration is free\"
or
img src="https://vborg.vbsupport.ru/green/top_register.gif\" ".

Plus it doesnt start the "s back in the else after the ".

PHP Code:

// guest/member register/usercp hack
if($bbuserinfo['userid'] != 0) {
    
$reg_ucp "<a href=\"usercp.php?s=$session[sessionhash]\">".
        
"<img src=\"https://vborg.vbsupport.ru/green/top_profile.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=\"https://vborg.vbsupport.ru/green/top_register.gif\" ".
        
"alt=\"Registration is free!\" border=\"0\"></a>";


Sorry for correting you! But I got lots of icky errors >.< (btw, I know that you typed it right. Its the [ php] 's fault that it edited the escapes out ^^)

Dark Odin 05-08-2002 06:51 PM

For Template driven:

PHP Code:

if($bbuserinfo['userid'] != 0) {
          eval(
"\$reg_ucp = \"".gettemplate("unregged")."\";");
        }else{
eval(
"\$reg_ucp = \"".gettemplate("regged")."\";");


Just create the templates unregged and place your register button code or link, and put your user cp link code in regged template.

Not sure if this works, but it looks like it should.

KuraFire 05-08-2002 09:43 PM

Dark Odin, your code is backwards. It currently gives unreg-templates for members, and regged-templates for guests. :)

Takara, actually, my hack said { imagesfolder } but if I type it without the spaces, it gets parsed... o_O

But it all looks commented out fine on _my_ screen, nonetheless.... o.o

Dark Odin 05-08-2002 10:23 PM

First attempt at posting anything. :D

scsa20 05-08-2002 10:43 PM

I did mine an easyer way (find this out by looking around the template mod. forum ;) ) and here's how I did mine (2 different ways)....for the buttons (I used this on 2 template sets), I just added the following to the "phpinclude" template:

PHP Code:

if ($bbuserinfo['userid']<"1") {
    
$regcp "<a href=\"register.php?s=$session[sessionhash]&action=signup\"><img src=\"{imagesfolder }/top_register.gif\" alt=\"Registration is free!\" border=\"0\"></a>";
} else {
    
$regcp "<a href=\"usercp.php?s=$session[sessionhash]\"><img src=\"{imagesfolder }/top_profile.gif\" alt=\"Here you can view your subscribed threads, work with private messages and edit your profile and preferences\" border=\"0\"></a>";
        
$vlogout "<a href=\"member.php?s=$session[sessionhash]&&action=logout\"><img src=\"{imagesfolder }/top_logout.gif\" alt=\"Log Out\" border=\"0\"></a>";
}
if (
$bbuserinfo['usergroupid']==6) {
    
$vadminbutton "<a href=\"/admin/index.php?s=$session[sessionhash]\" target=\"_blank\"><img src=\"{imagesfolder }/top_admin.gif\" alt=\"Go to your Admin Panel\" border=\"0\"></a>";
}

if (
$bbuserinfo['usergroupid']==7) {
    
$vmodbutton "<a href=\"/mod/index.php?s=$session[sessionhash]\" target=\"_blank\"><img src=\"{imagesfolder }/top_mod.gif\" alt=\"Go to your Mod Panel\" border=\"0\"></a>";


and then just replace <!-- toplinks --> down to <!-- /toplinks --> with:

Code:

  <!-- toplinks -->
  $vadminbutton
  $vmodbutton
  $regcp
  <a href="calendar.php?s=$session[sessionhash]"><img src="{imagesfolder }/top_calendar.gif" alt="Calendar" border="0"></a>
  <a href="memberlist.php?s=$session[sessionhash]"><img src="{imagesfolder }/top_members.gif" alt="Find other members" border="0"></a>
  <a href="misc.php?s=$session[sessionhash]&action=faq"><img src="{imagesfolder }/top_faq.gif" alt="Frequently Asked Questions" border="0"></a>
  <a href="search.php?s=$session[sessionhash]"><img src="{imagesfolder }/top_search.gif" alt="Search" border="0"></a>
  <a href="index.php?s=$session[sessionhash]"><img src="{imagesfolder }/top_home.gif" alt="Home" border="0"></a>
  $vlogout
  &nbsp;
  <!-- /toplinks -->

(make sure you remove the spaces between from {imagesfolder and })

or you can put this in the "phpinclude" template:

PHP Code:

//Administrative/Moderator Login
if ($bbuserinfo[usergroupid]==6) { //Admins
$adminlogin "<a href=\"admin/index.php\">Administrative Login</a><br>";
} elseif ((
$bbuserinfo[usergroupid]==5) or ($bbuserinfo[usergroupid]==7)) { //Mods
$adminlogin "<a href=\"mod/index.php\">Moderator Login</a><br>";
} else { 
//Everyone else
$adminlogin "";
}
//End Login Code 

then just add $adminlogin anywhere in the footer template..and remember, you can always play around with the code ;)

Takara 05-08-2002 11:00 PM

Quote:

Originally posted by KuraFire
Takara, actually, my hack said { imagesfolder } but if I type it without the spaces, it gets parsed... o_O

But it all looks commented out fine on _my_ screen, nonetheless.... o.o

Oooohhhhh, lol. I uploaded what mine looked like.

Anyway ^-^

KuraFire 05-08-2002 11:03 PM

scsa20: sure, that works too, but it's totally not necessary on my board (how the hell you found that "an easier way" is beyond me, though. :p ).
I have my Admin Panel on my Personal Bookmark Folder, so I just have to click on one link to get there, no matter _what_ site or page I'm browsing (so I can be on this forum and still jump there with 1 click). As for the Mod panel, they don't have anything to do there on my board except ban users, and that's something they don't often have to do at all, and usually I'm the one doing it anyhow.

But, thanks for the addition anyway, some other people might well appreciate it. :):up:

KuraFire 05-08-2002 11:06 PM

Takara, as a suggestion: export images as .GIF if they don't use a lot of colors (ie. forum screenshots, for instance) - top quality and very small filesizes. Much better than these horrid, horrid .jpg's :)

Birdie501 05-10-2002 02:50 PM

Hi,

does somebody know how i can put these function in a javascript coded menu?

I use the xmenu hack
https://vborg.vbsupport.ru/showthrea...ighlight=xmenu

and want to use this function?

Thanks alot!

KuraFire 05-14-2002 10:03 AM

I can't help you with that, if you still _need_ help, even.... :/

Birdie501 05-21-2002 11:27 AM

thanks, i found another solution, thanks!

FleaBag 05-21-2002 10:03 PM

Well for starters I'm using version 2.2.5, and nowhere in my global.php do I see the above mentioned reference. I tried putting this...

PHP Code:

if ($bbuserinfo['userid'] != 0) {
          eval(
"\$reglinks = \"".gettemplate("reglinks_on")."\";");
        }else{
eval(
"\$reglinks = \"".gettemplate("reglinks_off")."\";");


...in my phpinclude template, created the templates reglinks_on and reglinks_off, and put $reglinks in my HTML - but nothing happens. Anyone have any ideas?

KuraFire 05-22-2002 06:45 AM

Your root/global.php should have these two lines, somewhere around line 270-280:

PHP Code:

// ###################### Start templates #######################
//prepare default templates ********************** 

If they aren't in it, you're using some weird unoffical version of vB, OR a different language version.

If you can't find that, try finding this:

PHP Code:

if ($bbuserinfo['userid']==and $usereferrer and !$bbreferrerid and $referrerid) {
  if (
$r_id $DB_site->query_first("SELECT userid FROM user WHERE userid = '".addslashes($referrerid)."'")) {
    
vbsetcookie("bbreferrerid",$r_id[userid]);
  }


And add this below it:

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>";



It won't work through templates, since you'd have to have a global-in-global template, which doesn't exist in vB.

FleaBag 05-22-2002 01:17 PM

Well I'm using an official, English version of vBulletin [2.2.5] - yesterday I couldn't find that code in my global.php, but today I could. LOL. And rather than hardcoding it I used the template version I mentioned above and created the two relevant templates, all running great now. Thanks for the help anyway. :)

FleaBag 05-22-2002 01:18 PM

Hmmmm... But it doesn't work in my vBPortal on my test board. :(

FleaBag 05-22-2002 04:17 PM

Anyone have any knowledge on how I could go about making this work in non-vb pages, such as my vBPortal P_themeheader template? Would I need to include anything in the external files that the portal wouldn't do as default? All input is appreciated.

KuraFire 05-22-2002 04:50 PM

It'll work on any page where you include global.php

If you have non-vB pages, make sure to include global.php and it'll work. If you don't want to includ global.php, then there's no way for the page to know whether a user is a guest or a member.

FleaBag 05-22-2002 05:07 PM

I get this error when I try to include it...

Code:

Fatal error: Cannot redeclare stripslashesarray() in /web/gamerforums/board/global.php on line 14
...so I'm guessing it's already included somewhere, which is what I thought - which is why I don't understand why it will not work.

KuraFire 05-22-2002 07:28 PM

I think your version of PHP is just too old...

what version you running?

FleaBag 05-22-2002 09:12 PM

I'm running version 4.1.2 [February 27 2002], which is only outdated by one more release - so it isn't that.

FleaBag 05-28-2002 12:10 AM

*Bump...*

KuraFire 05-28-2002 06:32 AM

Err, see one of the sticky threads in the Full Releases forum. I believe one of 'm contains a small fix on that problem.

FleaBag 05-28-2002 01:15 PM

I've had the replacement code variables fix installed for a long time.

KuraFire 05-28-2002 01:24 PM

Then I have no idea. Is it a vBPortal page you're trying to include this on, or a non-vb page of your own?

And in which directory is it? Different from where your vB itself is?

FleaBag 05-28-2002 01:27 PM

It's the vBPortal pages, and it's in the web root, my forums are in root/forums.

KuraFire 05-28-2002 01:33 PM

Then it might be a problem with vBPortal, or you haven't properly hardcoded the real path to your admin/functions.php ?

FleaBag 05-28-2002 02:41 PM

I didn't realise I was supposed to hard code that path, any idea where I do it?

KuraFire 05-28-2002 09:51 PM

I believe you only have to do it in global.php

however, note that I am totally not sure whether this will have any effect on your vBPortal. With my old site, however, I had to hardcode the real path in global.php (at least) to make it all work a directory lower than my forums...

FleaBag 05-28-2002 10:15 PM

I tried that and it didn't work. Thanks for trying anyway mate, it's appreciated. :)

KuraFire 05-28-2002 10:26 PM

sorry it didn't work, and no prob :)

Boofo 06-14-2002 10:16 PM

I have a scrolling ticker box that I would like the guests to see but not the regular users. It is javascript. How could I call that with the banner option you have here? It uses a piece of code in the index.php and a .jar file that it calls.

Quote:

Originally posted by KuraFire
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.

Click here for an example
(where `register` is will be `user cp` when you're logged in).

I mean, why have a Register button for members available, and a User CP button available for guests? :)

Exactly, that makes no sense, therefore, this hack. :)


Instructions

Step 1: Open your global.php and find this line:

PHP Code:

// ###################### Start templates ####################### 

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!


KuraFire 06-14-2002 10:29 PM

why the HELL did you quote my post there?!

That was totally not necessary and annoying :/

As to your question, uhm, just put the javascript in place where it now has the Banner stuff?

Boofo 06-14-2002 10:36 PM

Why don't you chill out a little bit. That whole quote was by accident. And I didn't quite understand the blahblah stuff you had in the code and I wasn't sure what was supposed to go there, so I thought I'd better quote it. Relax. :)

Quote:

Originally posted by KuraFire
why the HELL did you quote my post there?!

That was totally not necessary and annoying :/


As to your question, uhm, just put the javascript in place where it now has the Banner stuff?



All times are GMT. The time now is 04:44 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01532 seconds
  • Memory Usage 1,893KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (14)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete