| Home » Categories » Multiple Categories |
Create gift subscriptions with Sitelok |
|
Article Number: 74 | Last Updated: Fri, Mar 15, 2013 at 1:48 AM
|
| For certain sites you may like to have an account created for a user that is not actually the person paying. So for example someone wants to send membership as a gift having the login details emailed directly to that user. Here is a way to do that using Paypal, a registration form and the Paypal plugin. You can access the example pages in the attachments below.
1) We will use a registration form to collect the required details. In this example we will get the name of the payer and a note from them to the actual member (recipient). The payers name will be stored in custom1 and the note in custom2 (these are optional though). We will also collect the name and email address of the recipient.
<?php require_once("slpw/sitelokregister.php"); ?>
<html>
<head>
<title>Gift Subscription Form</title>
</head>
<body>
<hq>Gift Subscription Form</h1>
<?php if ($registermsg!="") print $registermsg; ?><br>
<form name="sitelokregisteruser" action="subscribe-gift.php" method="POST">
<?php registeruser("TEMP","1","subscribe.php?oc=!!!ordercustom!!!","","","Yes","YNYYYY"); ?>
Your Name<br>
<input type="text" name="custom1" id="custom1" value="<?php echo $custom1; ?>"><br>
Note to recipient<br>
<textarea name="custom2" rows="4" wrap="soft" cols="37"><?php echo $custom2; ?></textarea>
<br>
Their Name<br>
<input type="text" name="name" id="name" value="<?php echo $name; ?>"><br>
Their Email<br>
<input type="text" name="email" id="emailemail" value="<?php echo $email; ?>"><br>
<input name="submit" type="submit" value="Pay and Send">
</form>
</body> </html> 2) The registration form when submitted successfully will create the recipients account in a temporary usergroup called TEMP. This will be updated to the correct usergroup after payment is confirmed. We will pass to the registration thank you page the created username so that can be passed through Paypal. This is all achieved using this line from the above
<?php registeruser("TEMP","1","subscribe.php?oc=!!!ordercustom!!!","","","Yes","YNYYYY"); ?>
The registration thank you page needs to call Paypal using a normal Sitelok Paypal button. So that the user doesn't need to click the button we use javascript to submit it. We also pass the created username through Paypal using the custom field.
<form name="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="paypal@yoursite.com">
<input type="hidden" name="item_name" value="Product Name">
<input type="hidden" name="item_number" value="id1">
<input type="hidden" name="amount" value="9.99">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="http://www.yoursite.com/subscribe-ok.php">
<input type="hidden" name="cancel_return" value="http://www.yoursite.com">
<input type="hidden" name="notify_url" value="http://www.yoursite.com/slpw/pay_paypal/slpaypal.php">
<input type="hidden" name="custom" value="<?php echo $_GET['oc']; ?>">
</form> <script language="JavaScript">
<!-- JavaScript
document.paypal.submit()
// - JavaScript - -->
</script> Just replace the above button with your own button remembering to remove the actual button itself and adding the custom field line
<input type="hidden" name="custom" value="<?php echo $_GET['oc']; ?>">
In the rare cases where a user may have javascript disabled you can also add the same button (keeping the button this time) in a <noscript> section (see the example pages).
3) In the Paypal plugin you need to set the product so that it adds the user to the required usergroup(s) as usual and also removes them from the TEMP usergroup. To have a usergroup removed form a usergroup just set the expiry time to -1
|
Attachments (1)
|
Using Sitelok with Freeway Pro
Added on Thu, Aug 16, 2012
Do you have a trial or demo version of Sitelok
Added on Mon, Aug 1, 2011
I am not receiving any address data when users are added via Paypal
Added on Tue, Sep 6, 2011
Can I use themes for the Sitelok control panel?
Added on Mon, Aug 1, 2011
Using PHPmailer with Godaddy
Added on Thu, Nov 24, 2011
Increasing the size of a custom field
Added on Tue, Sep 13, 2011
Can I modify the code in Sitelok
Added on Mon, Aug 1, 2011
How do I use drop down menus, checkboxes or radio buttons in forms?
Added on Mon, Aug 1, 2011
Is there a forum I can use on my site that can share the login with Sitelok?
Added on Tue, Sep 6, 2011
Custom fields are not being stored in the database
Added on Mon, Aug 15, 2011
|

1.07 KB )