Naming referrals

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PeterNRG
    Member
    • Apr 2001
    • 70
    • 3.6.x

    Naming referrals

    It would be cool to actually see which members are a result of user referral actions

    So instead of just having a number at a users profile, it could look like this:

    Referrals: 3 (John, James, Whoever)
    www.nrg.be - www.ultrashock.com
  • Freddie Bingham
    Former vBulletin Developer
    • May 2000
    • 14057
    • 1.1.x

    #2
    First add an index on the referrerid field in the user table.

    Then this sort of code in the getinfo section of member.php would get you on your way:

    PHP Code:
    $referrers $DB_site->query("SELECT username FROM user WHERE referrerid = '$userinfo[userid]'");
    while (
    $referrer $DB_site->fetch_array($referrers)) {
      if (
    $referrerlist) {
        
    $referrerlist .= ", ";
      }
      
    $referrerlist .= $referrer[username];

    Comment

    • PeterNRG
      Member
      • Apr 2001
      • 70
      • 3.6.x

      #3
      Wouldn't this be cool to have it as a standard feature?!
      www.nrg.be - www.ultrashock.com

      Comment

      • Freddie Bingham
        Former vBulletin Developer
        • May 2000
        • 14057
        • 1.1.x

        #4
        Perhaps linking the numbers of referrers to a window that listed the names as I have 120+ referrees on my forum.

        Comment

        • PeterNRG
          Member
          • Apr 2001
          • 70
          • 3.6.x

          #5
          What are we waiting for? hehe.

          Make this an official new feature, and release it as a hack for now.
          www.nrg.be - www.ultrashock.com

          Comment

          • PeterNRG
            Member
            • Apr 2001
            • 70
            • 3.6.x

            #6
            Originally posted by freddie
            First add an index on the referrerid field in the user table.
            I'm an inexperienced mySQL user, so help me out with this. How do I do it? I have phpMyAdmin installed, can it be done with that?
            www.nrg.be - www.ultrashock.com

            Comment

            • Chen
              Senior Member
              • Jun 2001
              • 8388

              #7
              Yes.

              Click on your forum's database name on the left side.
              Click on Properties for table 'user'.
              Find the 'referrerid' field, and click Index on its row.

              And that's it.
              Chen Avinadav
              Better to remain silent and be thought a fool than to speak out and remove all doubt.

              גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

              Comment

              • PeterNRG
                Member
                • Apr 2001
                • 70
                • 3.6.x

                #8
                Originally posted by FireFly
                Click on your forum's database name on the left side.
                Click on Properties for table 'user'.
                Find the 'referrerid' field, and click Index on its row.
                And that's it.
                That was too simple to be true . Should I take any precautions with future forum upgrades because of this indexing?




                freddie
                Then this sort of code in the getinfo section of member.php would get you on your way:
                $referrerlist displays ALL members, instead of just the referrers.
                www.nrg.be - www.ultrashock.com

                Comment

                • Chen
                  Senior Member
                  • Jun 2001
                  • 8388

                  #9
                  Open member.php.
                  Find
                  PHP Code:
                  eval("\$referrals = \"".gettemplate("getinfo_referrals")."\";"); 
                  and above it add
                  PHP Code:
                  $referrers $DB_site->query("SELECT username FROM user WHERE referrerid = '$userinfo[userid]'");
                  while (
                  $referrer $DB_site->fetch_array($referrers)) {
                    if (
                  $referralslist) {
                      
                  $referralslist .= ", ";
                    }
                    
                  $referralslist .= $referrer[username];
                  }
                  $referrals .= " (";
                  $referrals .= "$referralslist";
                  $referrals .= ")"
                  And you're done.

                  If you added the index correctly (you can see a list of indexes for a table at its end), this will work (works for me - here).
                  I would've release this as a hack, but it's really Freddie's code, so I won't.
                  Last edited by Chen; Fri 10 Aug '01, 2:18am.
                  Chen Avinadav
                  Better to remain silent and be thought a fool than to speak out and remove all doubt.

                  גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

                  Comment

                  • Chen
                    Senior Member
                    • Jun 2001
                    • 8388

                    #10
                    Just in case.
                    Chen Avinadav
                    Better to remain silent and be thought a fool than to speak out and remove all doubt.

                    גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

                    Comment

                    • PeterNRG
                      Member
                      • Apr 2001
                      • 70
                      • 3.6.x

                      #11
                      Way to go FireFly!

                      I feel this thread should be moved and combined here: http://www.vbulletin.com/forum/showt...threadid=25016 since it's an exellent hack, and maybe my other requests can also be taken care of.
                      www.nrg.be - www.ultrashock.com

                      Comment

                      • PeterNRG
                        Member
                        • Apr 2001
                        • 70
                        • 3.6.x

                        #12
                        Kier, thanks for your efforts, but now the total number disappeared.
                        www.nrg.be - www.ultrashock.com

                        Comment

                        • Chen
                          Senior Member
                          • Jun 2001
                          • 8388

                          #13
                          I think you should remove
                          PHP Code:
                          $referrals ""
                          from the top of the code Kier gave.

                          But maybe he put that in in purpose, I dunno.
                          Chen Avinadav
                          Better to remain silent and be thought a fool than to speak out and remove all doubt.

                          גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

                          Comment

                          • Freddie Bingham
                            Former vBulletin Developer
                            • May 2000
                            • 14057
                            • 1.1.x

                            #14
                            Considering that $userinfo[userid] is being returned from the getuserinfo() function, there is no need to intval() it since naughty people can't insert their own values in to. Putting the iif function in only serves to raise the code complexity without gaining any processing time but it always looks cool to do it that way. I personally don't see why you are defining variables to nothing that are not used in queries (and therefore not a security risk) unless we now have a policy of defining all variables before usage which I wasn't aware of. We also haven't a policy of freeing db results when we are done unless I forgot to attend that meeting.

                            Comment

                            • dwh
                              Senior Member
                              • Sep 2000
                              • 1224
                              • 3.0.0 Release Candidate 4

                              #15
                              Originally posted by freddie
                              Considering that $userinfo[userid] is being returned from the getuserinfo() function, there is no need to intval() it since naughty people can't insert their own values in to. Putting the iif function in only serves to raise the code complexity without gaining any processing time but it always looks cool to do it that way. I personally don't see why you are defining variables to nothing that are not used in queries (and therefore not a security risk) unless we now have a policy of defining all variables before usage which I wasn't aware of. We also haven't a policy of freeing db results when we are done unless I forgot to attend that meeting.
                              I'm confused, who are you replying to?

                              And how do you free db results, sounds like a nice trick, what does it mean?

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...