This Add On allows anyone to purchase a gift of membership. When a user purchases a membership level that is set up as a “Gift Level”, a customized discount code is created after checkout. The gift code can be claimed for a free membership, with an appropriate expiration date if configured, for the level selected in the Gift Level’s settings.
How it Works
- Users who purchase gifts will not be given a membership level in your site.
- Gift purchasers can log in as a user and view the history of purchases made, available gift codes, and claimed gift codes.
- Users can purchase as many gift codes as they want by completing checkout for each code to be gifted. At this time multiple gift codes cannot be purchased in a single checkout.
Installation
You must have the Paid Memberships Pro plugin installed and activated with a valid license type to use this Add On.
- Navigate to Memberships > Add Ons in the WordPress admin.
- Locate the Add On and click Install Now.
- To install this plugin manually, download the .zip file above, then upload the compressed directory via the Plugins > Add New > Upload Plugin screen in the WordPress admin.
- Activate the plugin through the Plugins screen in the WordPress admin.
Navigate to Memberships > Settings > Levels to create and manage gift membership levels.
Navigate to Memberships > Settings > Email Templates to modify default messages sent through this plugin.
Membership Level Settings
- Navigate to Memberships > Settings > Levels.
- Create a new level group.
- Create a new membership level for the “Gift Level” and configure additional settings.
Below is a list of the additional fields shown on the Edit Level page when using this Add On.
- Gift Level?: Check this box if you would like to set the membership level being edited as a gift level
- Level to Gift: Choose the membership level that a discount code should be created for when this gift level is purchased
- Allow Gift Emails: Check this box to allow customers to enter the recipient email address at checkout. If an email address is provided, the recipient will automatically receive an email containing a personalized message and a link to claim the gift code. You can customize the “Gift Recipient” template on the Memberships > Settings > Email Templates page in the WordPress admin.
- Gift Membership Expires: If left unchecked, the gifted membership will never expire.
- Gift Expiration Period: The length of time until a gifted membership will expire once redeemed.
For example, let’s say your membership site sells a $10 monthly membership called “Premium”. Using the Gift Membership Add On, you could create a level called “Gift of Premium” that entitles the recipient to 6 months of Premium membership.
You would set a $60 initial payment on the “Gift of Premium” membership. Then, in the “Gift Membership” settings, assign the “Level to Gift” as “Premium” with a “Gift Expiration Period” of 6 months.
Email Template Settings
The Gift Membership plugin adds three new email templates that you can use to modify the default messages sent as part of a gift purchase:
- Gift Recipient: This email is sent when the gift giver provides the recipient email address at checkout.
- Gift Purchased: This email is sent to the gift giver as confirmation of their purchase after checkout.
- Gift Purchased (admin): This email is sent to the admin as confirmation of gift purchase after checkout.
The default Gift Purchased email includes a “Gift Confirmation Message” for the membership level that was purchased. This message includes a link to checkout and claim the gift code generated through the purchase.
If you would like to overwrite any Gift Membership-related email, navigate to Memberships > Settings > Email Templates. Below is a list of additional template variables you can use to customize message:
!!pmprogl_giver_display_name!!
: The display name of the user that purchased the gift of membership.!!pmprogl_gift_message!!
: The personalized message the gift giver added at checkout, if available.!!pmprogl_gift_code!!
: The gift code (discount code) generated for this purchase!!pmprogl_gift_code_url!!
: A full URL to the membership checkout page for the gifted level that automatically applies the gift code.
Advanced Setup
In addition to the membership level settings for Gift Memberships, this Add On can also be set up by defining “gift giver” and “gift recipient” level relationships using PHP.
Developers can add this setup code to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.
$pmprogl_gift_levels
is an associative array containing arrays where the “gift giver” membership level IDs are keys, with the values being an array of discount code options for the gift level. Here are the available options explained in more detail:
Option Name | Option Description |
---|---|
level_id | Membership Level ID of the gift membership level. This can be found by going to Memberships > Membership Levels in the WordPress Dashboard. |
initial_payment | The initial payment for the gift membership level. |
billing_amount | The recurring billing amount for the gift membership level. |
cycle_number | The number of billing cycles for the gift membership level. |
cycle_period | The billing cycle period. Possible values are “Day”, “Week”, “Month”, and “Year” (without the quotes). |
billing_limit | The billing cycle limit for the gift membership level. |
trial_amount | The trial amount for the gift membership level. |
trial_limit | The number of cycles the trial should last for the gift membership level. |
expiration_number | The number of “expiration_period”s before the gift membership level expires. |
expiration_period | The duration of the period used by “expiration_number”. Possible values are “Day”, “Week”, “Month”, and “Year” (without the quotes). |
$pmprogl_require_gift_code
is a global variable containing an array of membership level IDs. This array specifies which membership levels should require a discount code at checkout.
// Make levels 2 and 4 require a discount code at checkout.
$pmprogl_require_gift_code = array(2,4);
Note: a user who has purchased gift codes can not use their own gift codes if the gift level is in this array.
Complete Example
Below is a full code example of using the (optional) PHP method to define the settings for this Add On
If you want to use custom code but would also like to allow gift delivery at checkout, please follow the one-time steps below to enable “Gift Recipient” emails. This is only required if you want to continue using the custom PHP method to define your Gift Membership settings.
- Edit the Membership Level that you would like to enable this functionality for.
- Check the “Gift Level?” box.
- Check the “Allow Gift Emails” box.
- Then, uncheck the “Gift Level?” box.
- Save the Membership Level.
At this time there is no other way to allow customers to enter the recipient email address at checkout via custom code.
Action and Filter Hooks
apply_filters( 'pmprogl_gift_code_settings', array $gift_code_settings );
do_action( 'pmprogl_gift_code_purchased', $code_id, $user_id, $morder->id );
Limitations
This plugin is not currently compatible with the following Add Ons:
This is a Plus Add On.
Plus Add Ons are included in all Plus or higher premium membership plans.