Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 06-08-2009, 05:59 PM
doa24uk doa24uk is offline
 
Join Date: Feb 2008
Posts: 91
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Is this right (sql query) for Paid Subscriptions

Hi guys,

I'm trying to make it so that once a paid subscription is processed, my users reputation points are automatically updated to reflect the subscription they've bought (as well as their primary usergroup being upgraded).

I have 2 subscriptions set up.

Subscription 1 = 20 rep points
Subscription 2 = 50 rep points

Ok here's the idea for my (pseudo-) code. This would go at the end of payment_gateway.php if I'm not mistaken....

Code:
SELECT * from subscriptionlog WHERE userid=$userid AND status=1
// This gets all info about the subscription where the status denotes it as active (therefore if a user has previous expired subscriptions it won't grab them)

switch

case=1 {

SELECT * from user WHERE userid=$userid;

$newreputation = $row['reputation']+20;

UPDATE user SET reputation=$newreputation, usergroupid=10 WHERE userid=$userid;
{

case=2{

SELECT * from user WHERE userid=$userid;

$newreputation = $row['reputation']+50;

UPDATE user SET reputation=$newreputation, usergroupid=10 WHERE userid=$userid;

default;
//Something went wrong, do nothing;
Would this work or do I need extra error checking to make sure failed transactions aren't included in this??


Many thanks in advance, I'm quite desperate for this!

DoA
Reply With Quote
  #2  
Old 06-11-2009, 02:56 PM
Carnage Carnage is offline
 
Join Date: Jan 2005
Location: uk
Posts: 760
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've been looking at doing something similar myself. From my research into how the process works i'd suggest taking a look at class_paid_subscription.php.

line 338 contains a hook thats called once a user has completed payment for a subscription.

PHP Code:
    /**
    * Creates user subscription
    *
    * @param    int        The id of the subscription
    * @param    int        The subid of the subscription, this indicates the length
    * @param    int        The userid the subscription is to be applied to
    * @param    int        The start timestamp of the subscription
    * @param    int        The expiry timestamp of the subscription
    *
    */
    
function build_user_subscription($subscriptionid$subid$userid$regdate 0$expirydate 0
Thats the method the hook appears in you would need to use $subscriptionid and possibly $subid in deciding what to do in your switch statement.

As a final note, try to use the vbulletin datamanagers for editing the users reputation as opposed to doing it manually.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:56 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03636 seconds
  • Memory Usage 2,167KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete