Rewarding your members encourages ongoing engagement and incentivizes renewals. This tutorial demonstrates awarding MyCRED points when members join your site and continue their membership with recurring payments.

Banner for Advanced Code Recipe Tutorial for Paid Memberships Pro

Recipe #1: Points at Membership Checkout

This recipe primarily utilizes the pmpro_after_checkout hook, triggering the awarding of MyCRED points immediately after a successful membership signup. It specifically leverages the mycred_add() function from the MyCRED plugin, using the $points, $reference, and $entry variables to record the points transaction. Additionally, this recipe creates an order note detailing the awarded MyCRED points.

About the First Code Recipe

This recipe awards MyCRED points upon the initial membership checkout. Optionally, you can set it up to reward only members who choose automatic renewal, complementing the Auto-Renewal Checkbox at Membership Checkout Add On.

The First Code Recipe

Adjust the $points variable and membership level IDs according to your preferences. The $reference variable defines the type of transaction, while $entry provides a descriptive note stored in MyCRED logs. Customize these for clearer tracking and reporting of points awarded.

Customize points for each membership level by setting the $points variable for each membership level’s ID in the switch statement.

Recipe #2: Points Awarded With Each Recurring Payment

This recipe uses the pmpro_added_order hook, awarding MyCRED points each time a successful order is created, including initial signups and recurring payments. The recipe checks the order status to confirm success and uses the mycred_add() function with customizable $points, $reference, and $entry variables. Additionally, this recipe creates an order note detailing the awarded MyCRED points.

About the Second Code Recipe

This recipe consistently rewards members with MyCRED points for each successful payment, motivating users to maintain active memberships and increasing long-term member retention.

The Second Code Recipe

Adjust the $points variable and membership level IDs to match your site’s needs. The $reference variable describes the type of transaction, and $entry offers a detailed description stored in MyCRED logs. These variables can be modified for clear and accurate record-keeping of awarded points.Customize points for each membership level by setting the $points variable for each membership level’s ID in the switch statement.

Adding the Recipe to Your Website

You can add this recipe 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.

Free Course: Membership Site Development—The Basics

Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.

Featured Image for Membership Site Development Course: The Basics


Was this article helpful?
YesNo