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.