vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Adding Referral Count to User Stats (https://vborg.vbsupport.ru/showthread.php?t=45557)

esawdust 11-09-2002 09:24 PM

Adding Referral Count to User Stats
 
Hi folks,

How would I go about adding "Referrals:" to the user stats at left (locatin, registered since, and posts, etc..)

I have installed the Refer Friends hack and want to add the # of referrals to this info. Also is there a variable ($referrals ??) that would present the users total referrals within the user stats on every post.

Thanks for any help.

Greg

Erwin 11-10-2002 03:15 AM

Not tested myself, but should work - try this:

In functions.php, find:

PHP Code:

    $post[off]=bbcodeparse($post[off],0,$allowsmilies); 

UNDERNEATH, add:

PHP Code:

  // Get referrals
  
if ($usereferrer) {
    
$refcount $DB_site->query_first("SELECT count(*) AS count
                                       FROM user
                                       WHERE referrerid = '
$post[userid]'");
    
$referrals $refcount[count];


Then, in your postbit, add this anywhere you like to show the referral count:

Code:

Referrals: #$referrals
Should work! However, this will add an extra query per post in a thread to the showthread page. There's no real way around this unfortunately, since the referral count needs a query to COUNT the variable from the database. :)

esawdust 11-10-2002 03:15 PM

Thanks for your reply Erwin!

I looked and looked for the snippet of code (an probably missed it :cross-eyed: ) to no avail.. (functions.php in VB 2.2.8)

Can you give me an idea where it may be? I did post the code on the 248-255 but it didn't work.

I have the postbit taken care of.

Here's my code:

Quote:

$post[useremail]="";
$post[icqicon]="";
$post[aimicon]="";
$post[yahooicon]="";
$post[homepage]="";
$post[findposts]="";
$post[signature]="";
$onlinestatus="";
}
// Get referrals
if ($userreferrer) {
$refcount = $DB_site->query_first("SELECT count(*) AS count
FROM user
WHERE referrerid = '$post[userid]'");
$referrals = $refcount[count];
}

// do ip addresses
if ($post[ip]!="") {
if ($logip==2) {
Seeing as how the user profile pulls the referrals already (assuming it's activated in vB) is there a $string already set that could be placed in the postbit? Or is that all done through a query also?

Thanks a bunch!

Greg

esawdust 11-10-2002 11:05 PM

bump

Erwin 11-10-2002 11:10 PM

Put the code in functions.php exactly where I say to put it - that line of code was taken from functions.php 2.2.8 unhacked - and then remember to edit your postbit template. It should work.

The referral count needs to be specifically queried from the database for the postbit.

esawdust 11-10-2002 11:59 PM

Okay... I still cannot find that "exact" line of code. I even performed a find and replace in Dreamweaver after manually scrolling 2300 plus lines and it wasn't found. Then I pulled a fresh vb.zip for the functions.php file (figuring maybe a hack modified it) and still no match.

Either I'm nuts, blind, or that code is not in there :) There is no code that starts with $post[off] whatsoever in the functions.php version 2.2.8.

Please advise?!?

Thanks for your time,

Greg

Erwin 11-11-2002 12:23 AM

Sorry, vB.org parsed the code I used.

Try to find this in functions.php instead:

PHP Code:

        eval("\$post[profile] = \"".gettemplate("postbit_profile")."\";"); 

Add my code ABOVE this.

See if that works.

esawdust 11-11-2002 04:53 PM

Okay.. found the code :) but it didn't work :( The Referrals: # shows up in my postbit but it's not logging the $referrals number.



Code:

                } else {
                        $post[pmlink] = "";
                }
// Get referrals
  if ($usereferrer) {
    $refcount = $DB_site->query_first("SELECT count(*) AS count
                                      FROM user
                                      WHERE referrerid = '$post[userid]'");
    $referrals = $refcount[count];
}
                eval("\$post[profile] = \"".gettemplate("postbit_profile")."\";");
                eval("\$post[search] = \"".gettemplate("postbit_search")."\";");
                eval("\$post[buddy] = \"".gettemplate("postbit_buddy")."\";");

Code:

<smallfont>Registered: $post[joindate]<br>
        Location: $post[field3]<br>
        Posts: $post[posts]<br>
                Total Referrals:#$referrals<br><br>
                Certifications: <br>$badge $badge2 $badge3<br>
                $onlinestatus</smallfont></td>       
        <td bgcolor="$post[backcolor]" width="100%"


Erwin 11-11-2002 05:01 PM

Try this code instead:

PHP Code:

// Get referrals
   
$refcount $DB_site->query_first("SELECT count(*) AS count FROM user WHERE referrerid = '$post[userid]'"); 

Put that where you tried the other code.

Then, in your postbit template, try this:

Code:

Referrals: #$refcount[count]

esawdust 11-11-2002 05:09 PM

Hi Erwin,

I made the changes... now when I click on a thread it gives me:

Quote:

Fatal error: Call to a member function on a non-object in /public_html/forums/admin/functions.php on line 228
Thanks again.

Erwin 11-11-2002 08:26 PM

Did you paste that in the right place? Your error message does not correlate with the query.

NTLDR 11-11-2002 08:40 PM

You need to make sure you have $DB_site listed with the globals at the top of the buildpostbit function.

Erwin 11-11-2002 08:51 PM

Do this:

In functions.php -

Find:

PHP Code:

// ###################### Start buildpostbit ####################### 

Underneath, add:

PHP Code:

global $DB_site 

Like I said, this is usually not done because you don't want to add 1 query per post per thread. But you wanted it.

esawdust 11-12-2002 12:10 AM

Quote:

Parse error: parse error, expecting `','' or `';'' in /public_html/forums/admin/functions.php on line 59

Fatal error: Call to undefined function: getuserinfo() in /public_html/forums/admin/sessions.php on line 365
Well :) ... I added the additonal piece of code as stated and it gave me the above errors. I also double checked the original code and all is in the locations you specified.

My intent for the count was to promote refers through a points/awards system. At 10 referal they can earn something, 25 points... and so on. I wanted to display it within the user stats to entice a competitive spirit :)

Maybe there's a better way of doing this?

Thanks again!

Greg

NTLDR 11-12-2002 06:14 PM

Make sure theres a ; on the end, ie:

PHP Code:

global $DB_site


esawdust 11-12-2002 06:55 PM

Quote:

Fatal error: Call to a member function on a non-object in /public_html/forums/admin/functions.php on line 230
:) Back down to one error .....

Greg

esawdust 11-12-2002 07:02 PM

I tried this with the first bit of code Erwin posted as well.. didn't work. Although there are no errors and everything works fine... just no referrals #

Greg

xXoOmegaoXx 01-28-2003 10:42 PM

did you paste "Referrals : #$referals;"?

IF you did, you ARE supposed to take out the pound (#) symbol ;)

Dean C 01-29-2003 03:24 PM

That's irrelevant buddy ^ the # is just what will apeare in the postbit template so it will like this:

PHP Code:

Referrals#4 

- miSt


All times are GMT. The time now is 03:51 AM.

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.01276 seconds
  • Memory Usage 1,775KB
  • 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
  • (4)bbcode_code_printable
  • (8)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (19)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