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.

has paid Shortcode for Paid Memberships Pro WordPress Plugin


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.

If you’re using the Memberlite Theme, you can use the [memberlite_btn] shortcode like this:

[memberlite_btn style="action" href="/membership-checkout/?level=1" text="Upgrade to Gold Membership" icon="heart"]

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:


Shortcode Attributes

  • 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.

Shortcode Examples

[haspaid]
This will show up if the user has paid for any level.
[/haspaid]
[haspaid paid='0']
This will show up if the user has NOT paid for any level.
[/haspaid]
[haspaid paid='1' level='1']
This will show up if the user has paid for level 1 specifically.
[/haspaid]
[haspaid paid='0' level='1']
This will show up if the user has not paid for level 1 specifically.
[/haspaid]

The Code Recipe

This code recipe requires a PMPro Plus Account or higher.

View Membership Options


Comments (12)

Author’s gravatar

I could not get it to work. It showed the conditional message for all levels, even though I specified the message to be visible only for level 2 members. I uninstalled the code. I tried it both in functions.php and in the PMPro Customizations plugin. I do not use Memberlite. I that the reason this code fails to work?

A related question: How do I set up additional “value-added” purchases for an existing paid Basic member without changing their membership level? I want the Basic member to be able to purchase as many extra services as they need (at $XX each). I want to make sure a new subscriber to the Basic level is not able to purchase any “value-added” services until they have subscribed to Basic.

Reply
Author’s gravatar

Thanks for the heads up. I’ll test again on other themes and see if a tweak is needed.

Your related question sounds like a good use for PMPro Addon Packages: https://www.paidmembershipspro.com/add-ons/pmpro-purchase-access-to-a-single-page/

Reply
Author’s gravatar

Can you share the shortcode/etc you tried? I tested on my dev setup again and it all worked well. Were you nesting the shortcodes like in Kim’s one example? It worked for me in memberlite and 2015, but I could see that failing in some themes that play around with the_content filters.

Author’s gravatar

Perhaps I am unclear on the nesting concept. I tried Kim’s example but the nested Memberlite button did not show up because I am not using Memberlite theme.

Author’s gravatar

Ahh. FYI, you can use the Memberlite Shortcodes plugin with non-memberlite themes, althought some are not really useful or may look odd with your theme.

https://wordpress.org/plugins/memberlite-shortcodes/

Also, PMPro comes with a checkout button that isn’t as featured as the Memberlite button, but can display a link to a level and be used there instead:

[pmpro_checkout_button level="20"]

Author’s gravatar

Thanks for your attention to my issue, Jason. The site is https://www.one2oneamerica.com. It uses Genesis Framework with the Education Pro theme from StudioPress. http://my.studiopress.com/themes/education/

My Membership Levels page had this shortcode which was visible to all levels 1 through 4:

[haspaid level=”2″ paid=”0″]
Unlock Additional Members-only Content!
You are currently on a free trial membership. To unlock additional content, please upgrade now to our “$2000 – Ready to Work” membership.
[/haspaid]
[pmpro_levels]

Author’s gravatar

Couple things:

1. Double check that the ” didn’t copy out as magic/fancy quotes. Replace them manually with the ” key on your keyboard. Magic quotes would mess up the parameters.

2. If you want that to only show up for level 1 members/etc, wrap the whole thing with a membership level=”1″ shortcode. (I think if I actually write the square brackets here, it may break our site.)

Otherwise, the shortcode you shared would show that message to anyone who has NOT paid for a level 2 order yet. So any non-user, anyone with a different level, or any level 2 user who hasn’t paid yet.

Thanks for your patience. These things can get confusing, and working this out helps us learn how to explain this.

Author’s gravatar

Jason, I only want to show that message to level 2 users whose next step (after a free trial) is to pay for level 3. I think I am complicating this because I failed to mention that level 1 is a hidden free membership role for our advisors (whose memberships are manually assigned by me in the backend).

Yes, I am confused. Should I wrap a level 2 shortcode around the existing level 2 shortcode message?

Author’s gravatar

Jason: I got it working. Thanks for your help. I will also try “Purchase Access to a Single Page” to handle the “extra services” that do not require a change to membership level.

Here is the code which now only appears to level 2 users:

[membership level="2"]
[haspaid level=”2″ paid=”0″]
Are you ready to go to the next level and start working with one advisor?
You are currently on a free trial membership. To work on your application essay with your chosen advisor, please upgrade now to our “$2000 – Ready to Work” membership.
[/haspaid]
[/membership]
[pmpro_levels]

Author’s gravatar

Where do we post the short code at? I put this listed below as the first thing on the page and it didnt work.

[haspaid paid=’1′ level=’4′]

Unlock Additional Members-only Content!
You are currently on a free casual trial membership. To unlock additional content, please upgrade now to a full membership such as our Founding Member level.
[pmpro_checkout_button level="2" text="Upgrade to Founding Member"]
[/haspaid]

Reply
Author’s gravatar

Have you added the code gist to a custom plugin?

You should just put the shortcode into post content like that. It won’t work in widgets and with some form builders by default. You’ll need to make sure that shortcodes are being processed in those places.

What happens when you add the shortcode? Is it blank? Is it always shown? Do you see the shortcode text on the front end.?

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *