This recipe will offer code to mark a membership level as a trial which can only be used once. It’s useful for people looking to add a “no credit card required” trial option.

To start create a membership level for your trial and set an expiration date for it. Note the id of this level. Update the code below to set $trial_level_id (in all three functions) to that value. Then this code will add a custom user meta value when a user gains the trial level and then block that user from checking out with that level again.


It should be noted that this will only keep one USER from checking out again. You’ll have to get clever if you want to keep people from using a different email address to sign up again for the trial.


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.

This entry was posted by Jason Coleman in Recipes and tagged . Bookmark the permalink. Last updated: November 23, 2011. Titled Offer Trial Memberships That Can Only Be Used Once

Hey,

I used this code but “Renew” and “Checkout / Submit and confirm” button is still visible, only message added for free trail member. Can you please help me to hide or stop user to check out again for free membership.

Hi there,

Although this thread is mostly very old, I am interested in Kimberly’s most recent comment.

It still seems that trials can be renewed indefinitely (which I don’t want). Do I need to edit PHP code as suggested in 2015, or is there a more current solution as Kimberly suggested?

Thanks!

–Joel

Is is possible to have 2 (two) or more different membership levels that can be used as a trial like above single level? I’m trying to segment my sign-ups so it may be easiest (for me) if I can offer separate trial levels based on use cases of my service – and then I can AR or communicate based on their interests. If possible – how should the code look if I wanted, say, level 12 an level 13 as trials?
FYI – I’m using your cool gist from https://www.paidmembershipspro.com/memberships-levels-page-order-hide-display-skip-mega-post/ to “hide” levels from display on the Memberships > Edit Level admin.hide the levels from the enduser . . . .(Option 2)

Thanks
Ward

The my_pmpro_registration_checks only checks the “main” level the user is checking out for. The function would have to be updated to also check the $pmpro_checkout_levels array in case the user selected a trial level as one of many levels they selected to check out for.

I have a question. Can we modify this so that once someone has used the trial membership (that they can no longer purchase again), the trial membership doesn’t show up on the PMP registration form as an option?

I have gotten around this issue by changing the text in the php file to read the same as what it is supposed to say when someone has never signed up for any membership before ‘Membership expires after 2 weeks’. So, at least everyone gets the same message. Would still be nice to have a permanent fix for this though, so the expired message could show at the appropriate time.

I just implemented this, but I’m having an issue. On the Membership Levels page, even with my dummy accounts that I use for testing that have never purchased any membership, the free trial membership says “You have already used up your trial membership. Please select a full membership to checkout.” They are still able to check out and get the free trial, but this error shouldn’t be visible to someone who has never had a membership before. Any help on this is appreciated!

Hi,

Can I ask what the values at the end of this line doing?

‘ add_filter(“pmpro_level_expiration_text”, “my_pmpro_level_expiration_text”, 10, 2); ‘

Thanks,
Sean.

The 10 is the “priority”. 10 is the default. Anything lower than 10 will be run earlier. Anything greater than 10 will be run later.

The 2 is the number of parameters the hooked to function is expecting. The function my_pmpro_level_expiration_text takes 2 parameters, so we put 2 there. This usually is the same as the number of parameters the hook passes along, but can sometimes be lower if you don’t need the later parameters.

More information here: https://codex.wordpress.org/Function_Reference/add_filter

Hi Jason,

Thanks for the replies above, hadn’t seen them until now but managed to figure it all out … many thanks!

Hi gus,

Any news on this being added to the plugin core ? I know you are busy with development but this seems like one of the most important requirements for a membership plugin?

I will try the code above first to see if I can get it to work and msg if not 😉

Thanks,
Sean.

We’ve actually started development on overhauling how we do trials in core. Included in that is moving features from the “subscription delays” and “set expiration date” plugins into core and also the “trial memberships that can only be used once” type functionality. Like many things, it’s actually a lot harder to do that than just say it. We might have that update out in Q1. In the meantime, if you post what you are trying to do in our member forums, we can suggest the best path forward for you.

Thanks for this. I will give it a go. However I do think it should be an option when one sets up the level. Any chance of adding it sometime soon? Tomorrow, day after? 🙂

Hello,

Is this script still usefull ? It is starting to getting old (2011), and I need it, but I would be sure it is not already intergrated in the last version.
If it is still valid, I will try it.
If not, I will not of course, but do you plan to integrate it in a future relase directly in PMPro ?

Thanks

This script will still work.

We might integrate this into core or our Subscription Delay add on, but I don’t know when that will be.

In the meantime, we can help you to tweak this to your needs in our member forum.

When I add this code to my custom plugin without the my blog shows a blank screen with no source code. Is it interfering with my other custom code?

I’m currently using
1) Automatically Cancel Membership After X Failed Payments
https://www.paidmembershipspro.com/2015/02/automatically-cancel-membership-after-x-failed-payments/

2) Change cancellation to set expiration date for next payment instead of cancelling immediately
https://www.paidmembershipspro.com/2013/08/change-pmpro-membership-cancellation-to-set-expiration-date-for-next-payment-instead-of-cancelling-immediately/

Hi Jason,

I just had the same problem as described above. The PHP error said that the same method was in there twice: my_pmpro_after_change_membership_level
It appears that this trial only once and the cancel to set expiration date instead of cancelling immediately have the same method… You can just rename one of them my_pmpro_after_change_membership_level2 instead of my_pmpro_after_change_membership_level for all of its parts, right?

Hi, I have created the custom plugin and added the code and changed the id to my user level but the plugin would not activate and is giving me the following error message : Parse error: syntax error, unexpected ‘<' in /home/sites/*********.com/public_html/wp-content/plugins/pmpro-customizations/pmpro-customizations.php on line 11

I tried to set a trial period but this would not allow me to charge as I am using Payflow.

I would really appreciate any help you can offer with this.

Thank you.

Leave a Reply

For faster support related to issues on your specific site please open a ticket in our members support area.

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