View Full Version : Miscellaneous Hacks - Gift Subscriptions
jamoss
12-24-2007, 10:00 PM
Looks like there was a huge need for a gift subscription hack, so I created one, attached. It allows users to extend or purchase board subscriptions for other users.
This has been implemented and tested on our boards, but it is in EARLY ALPHA! Please provide me with feedback/questions after you implement it.
Should take about 15 minutes to complete.
1. Create 1 plugin
2. Modify 2 templates
3. modify 1 script (payments.php) -- PLEASE backup and save your old script for upgrade purposes.
Let me know how it goes!
~ Jennifer
M-Tuning
12-25-2007, 08:04 PM
What's the purpose of this hack?
jamoss
12-25-2007, 08:59 PM
So users can purchase subscriptions for other users (not just themselves).
skrazydogz
12-25-2007, 09:16 PM
like a check :D
FleaBag
12-25-2007, 09:58 PM
I realized Pig's hack was in the graveyard recently, and I didn't have a backup. This is really appreciated, thanks.
Diana Notacat
12-26-2007, 01:12 AM
This is fantastic, thank you! <3
M-Tuning
12-26-2007, 08:41 AM
So users can purchase subscriptions for other users (not just themselves).
I get it, thank you.
Hornstar
12-26-2007, 09:56 AM
This is just one of the many things that would really make the subscriptions really great, if vbulletin had it in default.
Thanks for sharing :)
SVTCobraLTD
12-26-2007, 01:11 PM
How does this work? Does it add a link under the paid subscriptions? Anyone have a demo or screen shot?
SVT
Zaiaku
12-26-2007, 03:58 PM
Very nice idea. Great job!
jamoss
12-26-2007, 04:11 PM
User goes to their CONTROL PANEL and then clicks on PAID SUBSCRIPTIONS (which you have to have enabled and set up already).
It defaults to the user's username, but they can enter another member's username as a gift subscription. The rest of the checkout goes through normally.
The recipient is NOT notified. That is up to the gifter or the moderator. Some gifters want to remain anonymous.
Arachnophiles
12-26-2007, 09:39 PM
Nice hack, thank you :)
I think a nice addition would be the ajax type 'auto-fill' feature (ie that found in the PM and search) which finds the correct username as your typing.
Are there plans to modify for vB3.7 ?
Cheers,
Adam
the Sandman
12-27-2007, 12:49 AM
Thank you! :)
the Sandman
12-27-2007, 08:26 AM
I think you need to account for a table prefix in the file hack part of the mod.
Steeler Nation
12-27-2007, 01:50 PM
This is just one of the many things that would really make the subscriptions really great, if vbulletin had it in default.
Thanks for sharing :)
I agree - this should be a default for vBulletin.
The hack works great.
jamoss
12-27-2007, 07:40 PM
I think you need to account for a table prefix in the file hack part of the mod.
You're right.. I removed it by mistake. Will fix.
the Sandman
12-27-2007, 07:53 PM
You're right.. I removed it by mistake. Will fix.Thanks! :)
aakhan136
01-05-2008, 09:11 PM
Thanks
jilly
01-09-2008, 01:52 AM
testing it on 3.5.4 soon
*edit* - gave me an error message on 3.5.4 - I am upgrading to 3.7 in a few weeks - will try again..
Do you know what will happen if the user already has the subscription? Will it be able to tell the user already has it and give the attempted gifter that message? Also would be nice to have the option to be anonymous or not, and send some sort of text message with the gift, either from anonymous or from the real user..
kether1
01-11-2008, 08:01 PM
This works well with 3.6.8 patch level2. The only issue I have with it is that when someone enters a typo in the username field or types something like 'happy birthday kether' instead of just 'kether', they get a database error. I tried to figure out how to capture the error and redirect them back to the subscription page to correct the mistake, but I am not a programmer. The problem comes with the userid of the recipient if their name is typed wrong or if it doesn't exist.
My solution would be to send them to a page that automatically redirects back to the subscription page after they had time to read a short messsage that says again: "Please type only the username of the member for which you would like to purchase a gift subscription " Anyone have any way to do that?
-K
ringleader
03-18-2008, 07:31 PM
I wouldn't have even noticed. And my members are dumb enough to do this.
Find in payments.php:
Instead of (as provided)
//=== HACK: GIFT SUBSCRIPTIONS ===//
if ($_POST['giftname']!=$vbulletin->userinfo['username']) {
$goo=$db->query_read_slave("SELECT userid from ". TABLE_PREFIX ."user where username='".$_POST['giftname']."'");
while ($giftee = $db->fetch_array($goo))
{ $subid=$giftee['userid']; }
}
else {
$subid=$vbulletin->userinfo['userid'];
}
//=== HACK: GIFT SUBSCRIPTIONS ===//
Use this code that checks the member name and includes an error message
("Invalid recipient username. Please press the back button, enter the correct username and try again. <u>Click Here to See the Members List</u>"):
//=== HACK: GIFT SUBSCRIPTIONS ===//
if ($_POST['giftname'] != $vbulletin->userinfo['username'])
{
$goo=$db->query_read_slave("SELECT userid from ". TABLE_PREFIX ."user where username='".$_POST['giftname']."'");
if ($giftee = $db->fetch_array($goo))
{
$subid = $giftee['userid'];
}
else
{
eval(standard_error(fetch_error('pminvalidrecipien t')));
}
}
else
{
$subid = $vbulletin->userinfo['userid'];
}
//=== HACK: GIFT SUBSCRIPTIONS ===//
Terrie
04-05-2008, 06:51 PM
I notice after upgrading to 3.6.9 the upgrade gets added to the person
buying the gift subscription as opposed to the person who should be
receiving the gift.
Terrie
04-05-2008, 08:32 PM
Woops... Nevermind it seems payments.php got overwritten during the upgrade. :rolleyes:
I had to reinsert the hacks back in. :D
cookiepants
04-09-2008, 07:29 PM
Okay, total newbie question, but how do I create a plug in for this?
cookiepants
04-09-2008, 07:29 PM
oh never mind -- it's in the Plug in section of the Admin area.
Terrie
04-28-2008, 01:56 AM
In case anyone was wondering this hack works great in 3.7 RC4 :up:
DieselMinded
11-27-2008, 09:19 PM
Diesel this work on 3.7.4 ?
CSS59
07-03-2009, 04:27 AM
3.8.3?
Avimelech
08-12-2009, 03:46 PM
I tried inserting this into the brand new 3.8.4 and got an error message when I tried to execute a paid subscription, saying:
Database error in vBulletin 3.8.4:
Invalid SQL:
INSERT INTO paymentinfo
(hash, completed, subscriptionid, subscriptionsubid, userid)
VALUES
('0d336f6ad3eff6f2f898922e6eaeec2b', 0, 1, 1, );
MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 4
Error Number : 1064
Request Date : Wednesday, August 12th 2009 @ 12:33:06 PM
Error Date : Wednesday, August 12th 2009 @ 12:33:06 PM
Script : http://forums.escapeallthesethings.com/payments.php?do=order
Referrer : http://forums.escapeallthesethings.com/payments.php
IP Address : 190.241.15.100
Classname : vB_Database
MySQL Version : 5.0.67-log
I am attaching my payments.php in case anyone can see if I did it wrong
Shamil.
08-12-2009, 03:56 PM
I tried inserting this into the brand new 3.8.4 and got an error message when I tried to execute a paid subscription, saying:
Database error in vBulletin 3.8.4:
Invalid SQL:
INSERT INTO paymentinfo
(hash, completed, subscriptionid, subscriptionsubid, userid)
VALUES
('0d336f6ad3eff6f2f898922e6eaeec2b', 0, 1, 1, );
MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 4
Error Number : 1064
Request Date : Wednesday, August 12th 2009 @ 12:33:06 PM
Error Date : Wednesday, August 12th 2009 @ 12:33:06 PM
Script : http://forums.escapeallthesethings.com/payments.php?do=order
Referrer : http://forums.escapeallthesethings.com/payments.php
IP Address : 190.241.15.100
Classname : vB_Database
MySQL Version : 5.0.67-log
I am attaching my payments.php in case anyone can see if I did it wrong
In that SQL, there userid is missing. This plugin was built for 3.6, you're on 3.8, I'd imagine that something has changed between the versions.
Avimelech
08-12-2009, 06:10 PM
Thanks, good point. Except when I did the search and replace, the code that I found matched exactly what was supposed to be there.
Can you recommend how to handle this? I really want this plugin. Shall I ask the original poster if they have this working still on their forums and using 3.8 now?
Shamil.
08-12-2009, 07:56 PM
Thanks, good point. Except when I did the search and replace, the code that I found matched exactly what was supposed to be there.
Can you recommend how to handle this? I really want this plugin. Shall I ask the original poster if they have this working still on their forums and using 3.8 now?
Yep, that's the cuase of action :)
Avimelech
08-13-2009, 01:21 AM
OK, I confess I rechecked and found a wrong insertion point for the subscription template. It works now, with 3.8.4.
klaush
09-24-2009, 07:40 AM
Hi,
can You explain what exactly is to do?
Thanks!
OK, I confess I rechecked and found a wrong insertion point for the subscription template. It works now, with 3.8.4.
Martin Kiess
11-10-2009, 09:50 AM
Hello,
i installed this AddOn in version 3.8.4.
There was 1 thing wrong in the payments.php
do NOT add after:
($hook = vBulletinHook::fetch_hook('paidsub_order_start')) ? eval($hook) : false;
i added it after:
if ($_POST['do'] == 'order')
{
//=== HACK: GIFT SUBSCRIPTIONS ===//
if ($_POST['giftname'] != $vbulletin->userinfo['username'])
{
$goo=$db->query_read_slave("SELECT userid from ". TABLE_PREFIX ."user where username='".$_POST['giftname']."'");
if ($giftee = $db->fetch_array($goo))
{
$subid = $giftee['userid'];
$subusername = $_POST['giftname'];
}
else
{
eval(standard_error(fetch_error('pminvalidrecipien t')));
}
}
else
{
$subid = $vbulletin->userinfo['userid'];
$subusername = $vbulletin->userinfo['username'];
}
//=== HACK: GIFT SUBSCRIPTIONS ===//
Then i modified the template: subscription_payment
locate: <td class="panelsurround" align="center">
<div class="panel">
<div align="$stylevar[left]">
AFTER that, add:
<div class="fieldset">
Subscription for: <strong>$subusername</strong>
</div>
Ok, so it works
Martin
Avimelech
01-14-2010, 11:22 PM
Anyone got the updated instructions to get this working for VB4? Many of the code syntax is now changed for the variables manipulated for the GIFTNAME...but I have not learned the new syntax yet.
Crrrazzzy
02-05-2010, 06:43 PM
i would also be interested in this for VB4
sojobo
02-21-2010, 09:17 PM
I'd love to see this implemented into vB4 too, I don't know why it's not a core feature tbh.
MrWizard
03-03-2010, 06:34 AM
My team updated this for 4.0.2
https://vborg.vbsupport.ru/showthread.php?t=237351
Thanks for the original mod jamoss!
ZERO <ibis>
11-26-2010, 08:02 PM
Any ideas how to fix it so that "special" names work?
For example: <[X]> will not work as an accepted username.
What do I need to edit in order for this mod to support special characters?
Fixed:
Replace:
$goo=$db->query_read_slave("SELECT userid from ". TABLE_PREFIX ."user where username='".$_POST['giftname']."'");
With:
$sqlname = htmlspecialchars($_POST['giftname']);
$goo=$db->query_read_slave("SELECT userid from ". TABLE_PREFIX ."user where username='".$sqlname."'");
MoMan
03-23-2011, 03:45 AM
You should use $vbulletin->db->escape_string instead of htmlspecialchars and it'll work like a charm!
Hornstar
04-02-2011, 09:53 PM
For anyone using this.
What happens if User_A buys it for User_B and than User_A reverses the money? Will paypal know which user to remove the subscription from correctly?
Also will I be able to find out which user paid the money and to whom?
I think this line may need to change:
<input type="hidden" name="custom" value="$_POST[giftname]" />
So it includes both the user who bought it and who got the gift.
Maybe:
<input type="hidden" name="custom" value="$userinfo[username] for $_POST[giftname]" />
Would that work?
MikeJDance
02-18-2012, 04:16 PM
So users can purchase subscriptions for other users (not just themselves).
Thank you :D x
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.