Referral System

Started by SMFHacks.com Team, March 03, 2008, 01:02:01 PM

Previous topic - Next topic

Fustrate

#120
Yes, that's possible. You'll need to add a new row in the members table in your database, with these specifications:
Name: referrals_gave_prize
Type: int
Size: 1
Not Null
Default: 0


and in Subs-Post.php, find:
      updateMemberData($posterOptions['id'], array('posts' => '+'));

add this after it:
      // Referrals Easter Eggs (instead of those in Register.php). Not a guest, posts count here, etc.
      // Give it on the 5th post by default - or change to whatever you'd like.
      $target = 5;
      if($user_info['posts'] == $target){
         loadMemberData($posterOptions['id']);
         $memCon = loadMemberContext($posterOptions['id']);
         
         if($memCon['referrals_gave_prize'] != 1){
            // Reward with Karma
            // updateMemberData($memCon['referred_by'], array('karmaGood' => 'karmaGood + 25'));
   
            // Using SMF Shop?  Give them money
            // updateMemberData($memCon['referred_by'], array('money' => 'money + 100'));

            // And make sure they don't double dip in the future (delete a post, post again)
            updateMemberData($memCon['referred_by'], array('referrals_gave_prize' => '1'));
         }
      }


I haven't tested this, so it might not work. I don't see why it wouldn't, though...
Steven Hoffman
Former Team Member, 2009-2012

toups

#121
Quote from: YodaOfDarkness on July 18, 2008, 01:39:08 PM
Yes, that's possible. You'll need to add a new row in the members table in your database, with these specifications:
Name: referrals_gave_prize
Type: int
Size: 1
Not Null
Default: 0


and in Subs-Post.php, find:
      updateMemberData($posterOptions['id'], array('posts' => '+'));

add this after it:
      // Referrals Easter Eggs (instead of those in Register.php). Not a guest, posts count here, etc.
      // Give it on the 5th post by default - or change to whatever you'd like.
      $target = 5;
      if($user_info['posts'] == $target){
         loadMemberData($posterOptions['id']);
         $memCon = loadMemberContext($posterOptions['id']);
        
         // Reward with Karma
         // updateMemberData($memCon['referred_by'], array('karmaGood' => 'karmaGood + 25'));
  
         // Using SMF Shop?  Give them money
         // updateMemberData($memCon['referred_by'], array('money' => 'money + 100'));
      }


I haven't tested this, so it might not work. I don't see why it wouldn't, though...

And I would comment out the other code that gives them money currently? I think in register.php or something?

or actually better yet.. would this work using both..:
Leave the current money given for getting a referral.. then bonus money if that referral member posts and becomes active? say 5 for getting a referral then 5 more once they become active?

Not sure if both would work together.. lmk if it would! Thanks!

Fustrate

#122
Yes, it would work. Forgot one thing in the code... I'll update it.

EDIT: My last post is now updated.
Steven Hoffman
Former Team Member, 2009-2012

toups

Quote from: YodaOfDarkness on July 18, 2008, 08:09:31 PM
Yes, it would work. Forgot one thing in the code... I'll update it.

EDIT: My last post is now updated.

Well I put it in, seems to be working :D Thanks.

toups

Yoda, is it possible to have the referrals on the Memberlist also? Along with the
Status  Username  Email  Website  ICQ  AIM  YIM  MSN  Position  Date Registered  Posts

Have 1 for Referrals on that list with the #?

ArkServer

Quote from: toups on July 20, 2008, 09:52:26 AM
Yoda, is it possible to have the referrals on the Memberlist also? Along with the
Status  Username  Email  Website  ICQ  AIM  YIM  MSN  Position  Date Registered  Posts

Have 1 for Referrals on that list with the #?

This sounds like a good thin to have in this mod, i like your idea.

Fustrate

#126
yes, that is possible.

In Sources/Memberlist.php, replace
'posts' => array(
'label' => $txt[21],
'width' => '115',
'colspan' => '2'
)

with
'posts' => array(
'label' => $txt[21],
'width' => '115',
'colspan' => '2'
),
'referrals_no' => array(
'label' => $txt['referrals_referralsstats'],
'width' => '25'
),

MAKE SURE YOU REPLACE, DON'T JUST ADD THE LAST 4 LINES
and
'posts' => array(
'down' => 'mem.posts DESC',
'up' => 'mem.posts ASC'
)

REPLACE with
'posts' => array(
'down' => 'mem.posts DESC',
'up' => 'mem.posts ASC'
),
'referrals_no' => array(
'down' => 'mem.referrals_no DESC',
'up' => 'mem.referrals_no ASC'
),


In Themes/(your theme)/Memberlist.template.php, find
<td class="windowbg" width="100" align="left">
', $member['posts'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $member['post_percent'] . '" height="15" alt="" />' : '', '
</td>

and add this after it:
<td class="windowbg2">', $member['referrals_no'], '</td>
and replace every number 12 with a 13 in that whole function (template_main)
Steven Hoffman
Former Team Member, 2009-2012

crustybum

Help i am in big doo doo, i installed this mod, now we cat post or anything..just get this

Unknown column 'mem.referrals_no' in 'field list'
File: /home/content/c/r/u/crusty1/html/theforum/Sources/Load.php
Line: 896

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 1.1.5, while your database is at version 1.1.4. The above error might possibly go away if you execute the latest version of upgrade.php.

Anyone :(

Fustrate

can you copy and paste everything around line 896 in Load.php? Specifically after the "db_query(".
Steven Hoffman
Former Team Member, 2009-2012

crustybum

OK i managed to re install it, although it said there were errors i continued,    It seems ok, but have yet to fully test it on a dummy run (will try later) what i have noticed is that in profile the referral line is duplicated twice.. :-\

Chris

Fustrate

eaiset way to fix that is to go into Profile.template.php and seach for "referrals", and delete any duplicate code blocks.
Steven Hoffman
Former Team Member, 2009-2012

crustybum

Thanks, i will try that later, Just did a dummy run with "test" member but the referral didnt show up  :-\ when i logged back in...

crustybum

I just cant see where the duplicate code is, what am i looking for?

Chris

Apllicmz

Nice work
Update portuguese and brazilian uft8

<file name="$languagedir/Modifications.portuguese.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['referrals_findreferrer'] = 'Encontre Referrer';
$txt['referrals_who'] = 'Consulta Informações:';
$txt['referrallink_copy'] = '[Copiar]';
$txt['referrals_who_description'] = 'Será que alguém se referiu a este site?';
$txt['referrals_on'] = 'On';
$txt['referrals_referrer_not_found'] = 'O referindo membro não pode ser encontrada. Verifique bem o nome que referenciou. Ou deixe-o em branco.';
$txt['referrals_youwerereferred_by'] = 'Por';
$txt['referrals_referrals'] = 'Referências:';
$txt['referrals_referrals_hits'] = 'Referral Link Hits:';
$txt['referrals_noneyet'] = 'Nenhum ainda!';
$txt['referrals_top5referrers'] = 'Top 5 referencia (Por Referências)';
$txt['referrals_top5referrersbyposts'] = 'Top 5 referencia (por membros referidos postes)';
$txt['referrals_referralsstats'] = 'Refencials';
$txt['referrals_referred_by'] = 'Referidos por:';
$txt['referrals_link'] = 'Referências Link:';
$txt['referrals_membersreferred'] = 'Membros referidos';

]]></add>
</operation>
</file>

<file name="$languagedir/Modifications.brazilian.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['referrals_findreferrer'] = 'Encontre Referrer';
$txt['referrals_who'] = 'Consulta Informações:';
$txt['referrallink_copy'] = '[Copiar]';
$txt['referrals_who_description'] = 'Será que alguém se referiu a este site?';
$txt['referrals_on'] = 'On';
$txt['referrals_referrer_not_found'] = 'O referindo membro não pode ser encontrada. Verifique bem o nome que referenciou. Ou deixe-o em branco.';
$txt['referrals_youwerereferred_by'] = 'Por';
$txt['referrals_referrals'] = 'Referências:';
$txt['referrals_referrals_hits'] = 'Referral Link Hits:';
$txt['referrals_noneyet'] = 'Nenhum ainda!';
$txt['referrals_top5referrers'] = 'Top 5 referencia (Por Referências)';
$txt['referrals_top5referrersbyposts'] = 'Top 5 referencia (por membros referidos postes)';
$txt['referrals_referralsstats'] = 'Refencials';
$txt['referrals_referred_by'] = 'Referidos por:';
$txt['referrals_link'] = 'Referências Link:';
$txt['referrals_membersreferred'] = 'Membros referidos';

]]></add>
</operation>
</file>


<file name="$languagedir/Modifications.portuguese-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['referrals_findreferrer'] = 'Encontre Referido';
$txt['referrals_who'] = 'Consulta Informa&ccedil;&otilde;es:';
$txt['referrallink_copy'] = '[Copiar]';
$txt['referrals_who_description'] = 'Ser&aacute; que algu&eacute;m se referiu a este site?';
$txt['referrals_on'] = 'On';
$txt['referrals_referrer_not_found'] = 'O referindo membro n&atilde;o pode ser encontrada. Verifique bem o nome que referenciou. Ou deixe-o em branco.';
$txt['referrals_youwerereferred_by'] = 'Por';
$txt['referrals_referrals'] = 'Refer&ecirc;ncias:';
$txt['referrals_referrals_hits'] = 'Referral Link Hits:';
$txt['referrals_noneyet'] = 'Nenhum ainda!';
$txt['referrals_top5referrers'] = 'Top 5 refer&ecirc;ncia (Por Refer&ecirc;ncias)';
$txt['referrals_top5referrersbyposts'] = 'Top 5 refer&ecirc;ncia (por membros referidos postes)';
$txt['referrals_referralsstats'] = 'Refencials';
$txt['referrals_referred_by'] = 'Referidos por:';
$txt['referrals_link'] = 'Refer&ecirc;ncias Link:';
$txt['referrals_membersreferred'] = 'Membros referidos';

]]></add>
</operation>
</file>

<file name="$languagedir/Modifications.brazilian-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['referrals_findreferrer'] = 'Encontre Referido';
$txt['referrals_who'] = 'Consulta Informa&ccedil;&otilde;es:';
$txt['referrallink_copy'] = '[Copiar]';
$txt['referrals_who_description'] = 'Ser&aacute; que algu&eacute;m se referiu a este site?';
$txt['referrals_on'] = 'On';
$txt['referrals_referrer_not_found'] = 'O referindo membro n&atilde;o pode ser encontrada. Verifique bem o nome que referenciou. Ou deixe-o em branco.';
$txt['referrals_youwerereferred_by'] = 'Por';
$txt['referrals_referrals'] = 'Refer&ecirc;ncias:';
$txt['referrals_referrals_hits'] = 'Referral Link Hits:';
$txt['referrals_noneyet'] = 'Nenhum ainda!';
$txt['referrals_top5referrers'] = 'Top 5 refer&ecirc;ncia (Por Refer&ecirc;ncias)';
$txt['referrals_top5referrersbyposts'] = 'Top 5 refer&ecirc;ncia (por membros referidos postes)';
$txt['referrals_referralsstats'] = 'Refencials';
$txt['referrals_referred_by'] = 'Referidos por:';
$txt['referrals_link'] = 'Refer&ecirc;ncias Link:';
$txt['referrals_membersreferred'] = 'Membros referidos';

]]></add>
</operation>
</file>



crustybum

ok managed to remove the duplicate code, noticed i also have it duplicated in the "stats" section, where do i remove the duplicate code for that one? one more thing is there a solution for the "copy" button yet as it dosnt work.

Chris

Fustrate

That would be in Stats.template.php

Make sure you check all of these if you have duplicates:

Sources:
Profile.php
Stats.php
Themes:
Profile.template.php
Stats.template.php
Display.template.php
XML.template.php

There are a few more, but they're a lot less likely to matter.
Steven Hoffman
Former Team Member, 2009-2012

Adish - (F.L.A.M.E.R)

is non editable refferel possible as it was in the other refferl mod which was compatilble with 1.1.4 ?

like change this imge:-


to:-


This feature is useful for me as no1 can edit it and many users tell me that they dont get the credits for their refferl as users remove the name from the box.


Thanks for your help...

Fustrate

Untested, but should work:

Find in Register.template.php
echo ' <tr>
<td width="40%"><b>', $txt['referrals_who'] ,'</b>
<div class="smalltext">', $txt['referrals_who_description'], '</div></td>
<td><input name="referredby" id="referredby" type="text" size="30" value="', ( !empty($context['referrals']['referred_by_name']) ? $context['referrals']['referred_by_name'] : '' ) ,'" />
<a href="', $scripturl, '?action=findmember;input=referredby;sesc=', $context['session_id'], '" onclick="document.getElementById(\'referredby\').value=\'\';document.getElementById(\'referredon\').innerHTML =\'&nbsp;\';return reqWin(this.href, 350, 400);"><img src="', $settings['images_url'], '/icons/assist.gif" border="0" alt="', $txt['referrals_findreferrer'] ,'" /> ', $txt['referrals_findreferrer'] ,'</a><br /><span id="referredon" class="smalltext">', ( !empty($context['referrals']['referred_date']) ? $txt['referrals_on'].' '.$context['referrals']['referred_date'] : '' ) ,'</span></td>
</tr>';


Replace with
echo ' <tr>
<td width="40%"><b>', $txt['referrals_who'] ,'</b>
<div class="smalltext">', $txt['referrals_who_description'], '</div></td>
<td>
<input name="referredby" id="referredby" type="text" size="30" value="', (!empty($context['referrals']['referred_by_name']) ? $context['referrals']['referred_by_name'] . '" readonly="readonly" />' : '" />
<a href="' . $scripturl . '?action=findmember;input=referredby;sesc=' . $context['session_id'] . '" onclick="document.getElementById(\'referredby\').value=\'\';document.getElementById(\'referredon\').innerHTML =\'&nbsp;\';return reqWin(this.href, 350, 400);"><img src="' . $settings['images_url'] . '/icons/assist.gif" border="0" alt="' . $txt['referrals_findreferrer'] . '" /> ' . $txt['referrals_findreferrer'] . '</a><br />
<span id="referredon" class="smalltext">' . ( !empty($context['referrals']['referred_date']) ? $txt['referrals_on'] . ' ' . $context['referrals']['referred_date'] : '' )  . '</span>', '
</td>
</tr>';


It's also possible to lock it on the back end, but that's pretty rare that someone will go through the trouble to edit it in the first place with the new code.
Steven Hoffman
Former Team Member, 2009-2012

Adish - (F.L.A.M.E.R)

Ok thanks.. I am testing it and I will let you know.. :D

Adish - (F.L.A.M.E.R)

oo wait... 1st this main error...

parseArchive(): No package-info.xml in this mod! Is it corrupted?

What is the solution for this..???

Thanks..

Advertisement: