News:

SMF 2.1.6 has been released! Take it for a spin! Read more.

Main Menu

Referral system

Started by mager, April 21, 2005, 01:41:32 PM

Previous topic - Next topic

mager

I know this is a lot to ask for and I dont expect someone to just give me a mod to do this, but I think in the future this would be a good mod to make.  I was thinking a referral system, and everytime someone mkes an account they can say who told them to come, and then users can check their own referrals to see how many they have, and admins can check evreyones referrals.  I dunno how hard this is because im not a coder, but its just an idea, tell me what you think.
http://www.dnlforum.com  Dark and Light Unofficial Forum

klumy


Dinagyang

Anybody working on this?

mager

http://www.dnlforum.com  Dark and Light Unofficial Forum

dtm.exe

Quote from: mager on July 05, 2005, 07:50:51 PM
I doubt it.

??? wrote this one.

Open: Sources/Register.php

Look for:

// Register them into the database.
db_query("
INSERT INTO {$db_prefix}members
(" . implode(', ', array_keys($register_vars)) . ")
VALUES (" . implode(', ', $register_vars) . ')', __FILE__, __LINE__);
$memberID = db_insert_id();
updateStats('member');


add after:

// Handle referrals seperately.
if (!empty($_POST['referrals']))
{
$referrals = explode(',', $_POST['referrals']);
// Make sure there are no doubles!
$referrals = array_unique($referrals);
foreach ($referrals as $referral)
{
// Find and do this member seperately..
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE memberName = '$referral'
AND ID_MEMBER != $memberID", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
db_query("
UPDATE {$db_prefix}members
SET referrals = referrals + 1
WHERE ID_MEMBER = $row[ID_MEMBER]", __FILE__, __LINE__);
}
}


Open: Themes/default/Register.template.php

Look for:

<tr>
<td width="40%">
<b>', $txt[82], ':</b>
</td>
<td>
<input type="password" name="passwrd2" size="30" />
</td>
</tr>


add after:
<tr>
<td width="40%">
<b>Referrals:<div class="smalltext">Optional; Seperate multiple names with commas</div></b>
</td>
<td>
<input type="text" name="referrals" size="60" />
</td>
</tr>


Open: Themes/default/Profile.template.php
Look for:

elseif ($modSettings['karmaMode'] == '2')
echo '
<tr>
<td>
<b>', $modSettings['karmaLabel'], ' </b>
</td><td>
+', $context['member']['karma']['good'], '/-', $context['member']['karma']['bad'], '
</td>
</tr>';
echo '


add after:

<tr>
<td><b>Referrals: </b></td>
<td>', $context['member']['referrals'], '</td>
</tr>


FINALLY, run this query:

ALTER TABLE {yourdbprefix}members ADD referrals smallint(5) NOT NULL AFTER karmaGood


look for:

mem.memberIP, mem.location, mem.ICQ, mem.AIM, mem.YIM, mem.MSN, mem.posts, mem.lastLogin, mem.karmaGood


add after:
, mem.referrals,

You will need to do it twice..
then look for:

'karma' => array(
'good' => &$profile['karmaGood'],
'bad' => &$profile['karmaBad'],
'allow' => !$user_info['is_guest'] && $user_info['posts'] >= $modSettings['karmaMinPosts'] && allowedTo('karma_edit') && !empty($modSettings['karmaMode']) && $ID_MEMBER != $user
),


and add after:

'referrals' => empty($profile['referrals']) ? 0 : $profile['referrals'],


-Dan The Man

mager

Sorry, didnt realize, thanks a lot dan!
http://www.dnlforum.com  Dark and Light Unofficial Forum

dtm.exe

Quote from: mager on July 06, 2005, 12:31:42 AM
Sorry, didnt realize, thanks a lot dan!

No problem :).

-Dan The Man

Digital Frostbyte

at the risk of looking foolish... I'm a little confused about the last part of those instructions. Is that going to be found in the sql or one of the php files? I have all the edits i know of to me to the listed php files complete and i'm really interested in trying this one out so any help would be great.

dtm.exe

Quote from: umiya on July 10, 2005, 12:36:48 PM
were are the last edits made at?

What last edits?

-Dan The Man

eFishie

I think someone may have already written a referral mod here. :P
--Jon

Abstraction Point Electronic Music Community - We don't bite! Really! I promise!

Check out my newest song: Alive

Digital Frostbyte

Quotelook for:
Code:

         mem.memberIP, mem.location, mem.ICQ, mem.AIM, mem.YIM, mem.MSN, mem.posts, mem.lastLogin, mem.karmaGood


add after:
Code:

, mem.referrals,


You will need to do it twice..
then look for:
Code:

      'karma' => array(
         'good' => &$profile['karmaGood'],
         'bad' => &$profile['karmaBad'],
         'allow' => !$user_info['is_guest'] && $user_info['posts'] >= $modSettings['karmaMinPosts'] && allowedTo('karma_edit') && !empty($modSettings['karmaMode']) && $ID_MEMBER != $user
      ),


and add after:
Code:

      'referrals' => empty($profile['referrals']) ? 0 : $profile['referrals'],

Those are the ones i am confused about. Are those in the sql or a php file?

dtm.exe

Quote from: Digital Frostbyte on July 10, 2005, 01:47:59 PM
Those are the ones i am confused about. Are those in the sql or a php file?

The SMF PHP files, or course.

-Dan The Man

umiya

what exacty file tho, you never specifi which one

Digital Frostbyte

i have searched in all the php files listed and i have yeat to find those things in any of them

[Unknown]

Load.php, it looks like.

-[Unknown]

Digital Frostbyte

Quote from: [Unknown] on July 10, 2005, 06:54:26 PM
Load.php, it looks like.

-[Unknown]

100% correct thanks a lot [Unknown]  :D

Digital Frostbyte

I really hate being a pain but is there anyway to edit the amount of referals people have. I had a basic profile field setup before that would let  you to add it manualy. I would like to give people credit for thier referals with this now.

ÞħÞ

#17
Yup, its called phpMyAdmin ;)

edit: a simple php script could also be designed to do that...

| My Website [nofollow]
There are 10 types of people in the world:
Those who understand binary and those who don't

Digital Frostbyte

well right now i have to figure out why it's not working at all. It shows up on the page and in profiles like it should, but when people enter the person that refered them it does not raise the persons referals

cjexotic

I tryed this and get an error  :'(
QuoteUnknown column 'mem.referrals' in 'field list'
File: /home/cjexotic/public_html/yabbse/Sources/Load.php
Line: 469

Any idea what I'm doing wrong?


Luckily I know and admit this stuff isn't easy for me :-[ so I just uploaded an unaltered copy of Load.php for now so  to do away with the error and keep my forum working,but eventually I'd like to get this referal thing working.

Advertisement: