Jeremiah Sturgill

code etc.

Fresno Filmworks Subscription Memberships

I’m on the board of Fresno Filmworks, a non-profit in Fresno, CA. This year they added a membership option to their year-end fund drive, with some perks thrown in depending on the amount contributed.

The FFW site doesn’t have a proper ecommerce system set up; instead, they rely only on PayPal buy-now buttons (don’t get me started). When they asked me to come up with a way for prospective members to stretch their donations out over the course of a year, I immediately thought of PayPal subscriptions. Similar to the buy-now buttons, this system allows for recurring payments to be set up with virtually zero infrastructure. The “classic” PayPal API may not have many bells and whistles, but it’s dog-simple and it works in a pinch.

The first step was creating a backend to allow non-techy board people to add or remove membership levels. Simple enough through WordPress custom post types. I also wanted fields for the price(s) of each level, to allow the subscribe button text to be customized, and for the perks given at the supplied level. The Plugin Foundation made it simple:

- Slug: membership
  Singular: Membership
  Plural: Memberships
  Has Archive: true
  Capability Type: [membership, memberships]
  Supports: [revisions, title, editor, thumbnail]
  Editor Roles: [super administrator, administrator, membership_editor]
  Messages:
    1: Membership updated.
    2: Custom field update.
    3: Custom field deleted.
    4: Membership updated.
    5: Membership restored to revision.
    6: Membership created.
    7: Membership saved. 
    8: Membership submitted.
    9: Membership scheduled for the future.
    10: Draft updated
  Labels:
    all_items: Memberships
    menu_name: Memberships
  Taxonomies: []
  Meta Boxes: 
    - ID: membership_info
      Title: Membership Information
      Fields:
        - Name: button_text
          Title: Button text
          HTML: <p class="tip"><em>Be consistent!  The default, if left blank, reads "become a [title]"</em></p>
          Type: textbox
        - Name: membership_price
          Title: Price
          HTML: <p class="tip"><em>Digits only, no decimals, no thousands separator.  If multiple prices are entered, there will not be a subscription option.  If the price is less than $100, there will not be a subscription option.</em></p>
          Type: textbox
          Repeatable: true
        - Name: membership_perks
          Title: Perks/Rewards
          Type: textbox
          Repeatable: true

The above snippet added the custom memberhsip post type and created the button text, price, and perks fields. The Repeatable: true marker for the price and perk fields allow for multiple entries. Like all repeating fields created with the plugin foundation, they can be dynamically created, removed, and reordered on the backend via JavaScript.

The membership posts are ordered by their date of publication. Reordering the list is as simple as altering the date of publication.

The board also wanted only memberships above a certain dollar amount to be elligible for subscription payment. I added some options to the backend to control various settings related to the memberships:

- Slug: paypal_options
  Options Group: paypal_options
  Menu Type: sub
  Parent Menu: 'options-general.php'
  Label: Paypal Config
  Title: Paypal Configuration
  Sections:
    - ID: paypal
      Title: Paypal Options
      Settings:
        - Name: paypal_email
          Title: Email
          Type: textbox
        - Name: paypal_status
          Title: Live or Testing?
          Type: pulldown
          Source:
            - text: live
              value: live
            - text: testing
              value: testing
- Slug: ffw_memberships
  Options Group: membership_options
  Menu Type: sub
  Parent Menu: 'options-general.php'
  Label: Memberships
  Title: Membership Options
  Sections:
    - ID: membership
      Title: Memberships
      Settings:
        - Name: intro_text
          Type: textarea
          Title: Intro Text on Membership Page
          Validator: JDSPFCoreFunctionspass_input
        - Name: outro_text
          Type: textarea
          Title: Outro Text on Membership Page
          Validator: JDSPFCoreFunctionspass_input
        - Name: cancel_url
          Type: textbox
          Title: Cancel URL
        - Name: return_url
          Type: textbox
          Title: Return URL
        - Name: subscription_min
          Type: textbox
          Title: Minimum level for subscription option
          HTML: <p class="tip">In dollars, no thousands seperators or decimal points (just digits: 0123456789)</p>

The above snippet creates an option page for Paypal and another page for memberships. The PayPal option page asks for the account email address and provides a pulldown list that can be used to switch payments between the live PayPal server and the sandbox server for testing. The membership page allows for text to be added before and after the memberships are listed, and it also provides a way to set the return URL, the cancel URL, and the minimum dollar amount required before a membership level can be paid for over the course of a year instead of all at once.

I then created a custom archive template, membership-archive.php to display the posts, create the encrypted PayPal buttons, and handle the various conditions:

  1. Memberships with single prices above the subscription cutoff
  2. Memberships with single prices below the subscription cutoff
  3. Memberships with multiple prices above the subscription cutoff
  4. Memberships with multiple prices below the subscription cutoff

The end result is that without much coding at all, Fresno Filmworks wound up with a simple, user-friendly backend to create and promote memberships that allow for multiple methods of payment.

Not bad for a few hours’ work.