vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Change Usergroup/Member Instant Rank Update (https://vborg.vbsupport.ru/showthread.php?t=257462)

brandondrury 01-20-2011 09:58 AM

Change Usergroup/Member Instant Rank Update
 
Well, I've wasted all night on this stupid thing, but I now have it where I can upgrade a member to a new membergroup/usergroup and their rank image will show up instantly without the need to update User Title and Rank counters.

I used "normal" code (whatever that means) in vB3.8.6, but for some reason in vB4 I had to update counters. This is unacceptable as the people buying my high priced stuff expect a little 643kb gif image next to their name NOW. :D

It turns out that this junk was the solution: http://www.vbulletin.com/docs/html/m...er_programming I'm a total idiot when it comes to object programming so I just pushed button until it worked.

I'm no programmer. I haven't done anything serious in 4 years and even then I was flying by the seat of my pants. Fair warning! If someone better wants to clean up the first-grader-with-crayon-like code, be my guest. Nowhere did I find this in my searches.

It's totally unsupported because I barely got the stupid thing to work.

Explanation:
It uses the global.php file to see if the dude is logged in. If he is, it digs up any current membergroups and adds 21 (in this example) to the end. This is necessary because in the past I'd lose my previous membergroups without it. For all I know, the object stuff takes care of this.

You'll need to change the pathways. This thing runs on a normal ol' php page and doesn't use the forum theme or anything like that. I used the

if ($upgrade=1) { echo "You are upgraded!"} else { echo "you need to log in"}

Here's my code:

PHP Code:

<?php
//$curdir = getcwd ();

require_once('global.php');
require_once(
'includes/functions.php');
require_once(
'includes/class_core.php');

//chdir ($curdir);
$forumpath="http://localhost/forum_real/";
$userid=$vbulletin->userinfo['userid'];
$usergroup=$vbulletin->userinfo['usergroupid'];
$membergroupids$vbulletin->userinfo['membergroupids'];


if (
$membergroupids)
    {
    
$groupIDs explode(','$membergroupids);
    }

$countercount($groupIDs);

// Change this to the usergroup ID you'd like to add this dude/chick to
$groupIDs[$counter]=21;


if (
$userid)
{
sort($groupIDs);
$groupIDsarray_unique($groupIDs);
$comma_separated implode(","$groupIDs);
$upgrade=1;
$dataman =& datamanager_init('User'$vbulletin); 
$dataman->set_existing($vbulletin->userinfo); 
$dataman->setr('membergroupids',$comma_separated); 

 
$vbulletin->userinfo['userid'
        = 
$userid 
        
$dataman->save();
}

?>


In case anyone needs the login code, here it is:

PHP Code:

echo"<form action=\"".$forumpath."/login.php\" method=post onsubmit=md5hash(vb_login_password,vb_login_md5password,vb_login_md5password_utf)>
    <script type=text/javascript src=\""
.$forumpath."/clientscript/vbulletin_md5.js\"></script>
    User Name:<br>
    <input name=vb_login_username type=text id=navbar_username onfocus=if (this.value == '
$vbphrase[username]') this.value = ''; size=10 />
            
    <br>Password:<br>
    <input name=vb_login_password type=password size=10 />
    </br>
        
    <input name=cookieuser type=hidden id=cb_cookieuser_navbar value=1 checked=checked />

    
        
    <input type=submit title=
$vbphrase[enter_username_to_login_or_register] value=\"Log In\" />
        
    <input type=hidden name=s value=
$session[sessionhash] />
    <input type=hidden name=do value=login />        
    <input type=hidden name=vb_login_md5password />
    <input type=hidden name=vb_login_md5password_utf />

    </form>"




All times are GMT. The time now is 11:47 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.01099 seconds
  • Memory Usage 1,731KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete