If you accept donations, or if you would like the customer to be able to choose an arbitrary amount that they will pay you for access, we suggest the use of an s2Member Pro-Form (available in s2Member Pro).


Step 1. ezPHP For WordPress

Install the ezPHP plugin provided by s2Member. This is required if you intend to use PHP tags in a Post/Page (or together with a shortcode). This plugin is what makes arbitrary amounts possible.


Step 2. Generate an s2Member Pro-Form Shortcode

See: WordPress Dashboard s2Member Stripe Pro-Forms

Note: this example uses Stripe, but the same technique works with other payment gateways also.

Generate an s2Member Pro-Form shortcode as you normally would. Set the amounts to anything you like, we will alter them later with the ezPHP plugin. For now, the most important thing is just to have an s2Member Pro-Form shortcode prepared. One that provides access to the Membership Level and CCAPs that you want to offer.

[s2Member-Pro-Stripe-Form level="1" ccaps="" desc="$0.50 USD / One Time (for lifetime access, non-recurring, no trial)" cc="USD" ta="0" tp="0" tt="D" ra="0.50" rp="1" rt="L" rr="BN" coupon="" accept_coupons="0" default_country_code="US" captcha="0" /]

Step 3. Insert the s2Member Pro-Form Shortcode Into a Post/Page

The URL to this page might be something like: http://example.com/checkout/

2015-07-09_11-10-46


Step 4. Make the Amount Dynamic; Based On An Input Variable

Working with: http://example.com/checkout/

This is where the magic happens. Using the ezPHP plugin, we set the $amount variable to the value of $_GET['amount']. The superglobal variable $_GET['amount'] comes from the query string; e.g., http://example.com/checkout/?amount=5.00. Thus, the amount that a customer is charged is defined by the query string variable: ?amount=[amount]

<?php
$amount = (float)@$_GET['amount'];
if($amount <= 0) $amount = '0.50'; // Default amount.
$amount = number_format($amount, 2, '.', ''); // Format the amount with two decimal points.
?>

[s2Member-Pro-Stripe-Form level="1" ccaps="" desc="$<?php echo esc_attr($amount); ?> USD / One Time (for lifetime access, non-recurring, no trial)" cc="USD" ta="0" tp="0" tt="D" ra="<?php echo esc_attr($amount); ?>" rp="1" rt="L" rr="BN" coupon="" accept_coupons="0" default_country_code="US" captcha="0" /]

Notice that we changed the hard-coded amounts in the shortcode to <?php echo esc_attr($amount); ?> instead. This way the Pro-Form shortcode is configured with the correct/dynamic amount.

2015-07-09_11-13-11


Step 5. Build An Amount Entry Form

The URL to this page might be something like: http://example.com/donate/

<form method="get" action="/checkout/">
    <label>Amount:</label>
    <input type="number" name="amount" />
    <button type="submit">Proceed to Checkout</button>
</form>

2015-07-09_11-16-26

2015-07-09_11-17-29


Step 6. Accept Donations!

Direct those who will donate to: http://example.com/donate/ where they will enter the amount they want to donate and submit the amount entry form. This will move them over to: http://example.com/checkout/?amount=[amount they entered] where your ezPHP + s2Member implementation picks up the amount and presents an s2Member Pro-Form preconfigured with the amount they want to pay you.