Skip to content

Commit 8e00b3a

Browse files
v1.2
Signed-off-by: Diego Andrés <diegoandres_cortes@outlook.com>
1 parent 2194e9e commit 8e00b3a

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

Sources/SimpleReferrals.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* @package Simple Referrals
5-
* @version 1.0
5+
* @version 1.2
66
* @author Diego Andrés <diegoandres_cortes@outlook.com>
77
* @copyright Copyright (c) 2021, SMF Tricks
88
* @license https://www.gnu.org/licenses/gpl-3.0.en.html
@@ -82,6 +82,9 @@ public static function save_referral(&$regOptions, &$theme_vars, &$knownInts)
8282
$smcFunc['db_free_result']($request);
8383
}
8484

85+
// Update the session with the input user? I don't think it's relevant for the mod, but will leave here just in case
86+
// $_SESSION['signup_referral'] = (int) self::$_member_id;
87+
8588
// Insert the value
8689
$regOptions['register_vars']['referral'] = self::$_member_id;
8790

@@ -115,6 +118,10 @@ public static function update_count($regOptions)
115118
]
116119
);
117120
}
121+
122+
// If we still have the referral in the session, remove it
123+
if (isset($_SESSION['signup_referral']))
124+
unset($_SESSION['signup_referral']);
118125
}
119126

120127
/**
@@ -129,21 +136,15 @@ public static function register()
129136
{
130137
global $context, $txt, $modSettings;
131138

132-
// Help SMF remember the referral
133-
if (!empty($context['agreement']) || !empty($context['privacy_policy']))
134-
{
135-
if (!empty($context['agreement']))
136-
$context['agreement'] .= '<input type="hidden" name="referral" value="' . (isset($_REQUEST['referral']) && !empty($_REQUEST['referral']) ? (int) $_REQUEST['referral'] : '') . '">';
137-
else
138-
$context['privacy_policy'] .= '<input type="hidden" name="referral" value="' . (isset($_REQUEST['referral']) && !empty($_REQUEST['referral']) ? (int) $_REQUEST['referral'] : '') . '">';
139-
}
139+
// Save the referral in the session
140+
$_SESSION['signup_referral'] = (int) (isset($_REQUEST['referral']) && !empty($_REQUEST['referral']) ? $_REQUEST['referral'] : (isset($_SESSION['signup_referral']) && !empty($_SESSION['signup_referral']) ? $_SESSION['signup_referral'] : 0));
140141

141142
// Auto suggest
142143
loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest');
143144

144-
// Do we have a referrer in the url?
145-
if (!empty($_REQUEST['referral']) && isset($_REQUEST['referral']))
146-
self::$_member_id = (int) $_REQUEST['referral'];
145+
// Do we have a referrer in the session/url?
146+
if (!empty($_SESSION['signup_referral']) && isset($_SESSION['signup_referral']))
147+
self::$_member_id = (int) $_SESSION['signup_referral'];
147148
// Maybe we are returning to some errors?
148149
elseif (!empty($_REQUEST['simple_referrer_id']) && isset($_REQUEST['simple_referrer_id']))
149150
self::$_member_id = (int) $_REQUEST['simple_referrer_id'];

Themes/default/languages/SimpleReferrals/.english.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$txt['maintain_recountreferrals_info'] = 'Run this maintenance task to update your users referral count. It will recount all (countable) referrals they have and then update their profile referral totals';
1919
$txt['SimpleReferrals_settings'] = 'Simple Referrals Settings';
2020
$txt['SimpleReferrals_allow_select'] = 'Only allow direct links';
21-
$txt['SimpleReferrals_allow_select_desc'] = 'If enabled, guests will not be able to find/set forum users in the signup form, can only use direct referral links.';
21+
$txt['SimpleReferrals_allow_select_desc'] = 'If enabled, guests will not be able to search/set forum users in the signup form, can only use direct referral links.';
2222
$txt['SimpleReferrals_enable_posts'] = 'Enable referrals count in posts';
2323
$txt['SimpleReferrals_enable_profile'] = 'Enable referrals count in profile';
2424
$txt['SimpleReferrals_display_link'] = 'Display the referral link in profile';

package-info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
44
<id>smftricks:simplereferrals</id>
55
<name>Simple Referrals</name>
6-
<version>1.1</version>
6+
<version>1.2</version>
77
<type>modification</type>
88
<install for="2.1 - 2.1.99, 2.1 RC4">
99
<!-- Mod Readme -->

0 commit comments

Comments
 (0)