The code recipe below to creates a renewal button shortcode
[pmpro_renew_button] that can be used to insert a “Renew Membership” button on your WordPress site.
I’ve been asked this simple question many times recently: “How do I display the current user’s membership level in my theme?”
This post details how to use the
[pmpro_member] shortcode, included in the main plugin, to show specific information about the current logged in user’s membership.
Why would you want to do this?
We created the
[pmpro_member] shortcode so that you can build a more robust and personalized experience on your membership site.
How to use the shortcode:
You can place this general shortcode anywhere in your site, either in post content or widgets, or via template files using the WordPress
Available shortcode attributes:
The shortcode accepts one single parameter, with a specific set of values as listed below. These values will pull the data directly from the current logged in user record.
Supported “field” Values Include:
Membership Level Fields:
Fields Stored in the
Payment Fields Stored in
Jason just coded up a new shortcode feature for a support customer and we wanted to share it—hooray open source! It’s a little tricky to explain, but once you wrap your brain around the features, you’ll begin to think of interesting ways to apply it to your membership site.
The shortcode is primarily useful for sites that offer free trials and want to show (or hide) content to users who are on the trial vs. those that are full paying members.
A little more detail…
The “haspaid” shortcode detailed below looks up a member’s order history and checks whether their current level or any past levels have a positive order total value. Then, using the shortcode attributes, you can show or hide content only to members that match your criteria.
For example, the image above shows an upgrade message to members on a free trial of level ID 1 that have NEVER paid for the level. This is the shortcode and content used to create that callout.
Members of level ID 1 that are paying (full members) will not see this callout or any interruption in the standard content of your page/post.
Another example may be to wrap the
[haspaid] shortcode inside of the
[membership] shortcode to show an upgrade notice to members who USED to be a higher tier and are now a lower tier. For example:
- paid: Accepts ‘true’ (has paid) or ‘false’ (hasn’t paid); default: true
- level: The level ID to check against. Accepts any level ID; default: none.
This will show up if the user has paid for any level.
This will show up if the user has NOT paid for any level.
[haspaid paid='1' level='1']
This will show up if the user has paid for level 1 specifically.
[haspaid paid='0' level='1']
This will show up if the user has not paid for level 1 specifically.
The Code Recipe
If you want to use a Paid Memberships Pro shortcode in a widget, your theme must declare support for shortcodes in widget_text.