This will not work well with PayPal Standard Buy Now (HTML) buttons. Even with Auto-Return enabled, there is no guarantee the user will make it back to your thank you page. If they close the browser before the redirect happens (which will happen often) then they would never make it there and that code would never run. If you want to try this sort of a solution you will need to use the PayPal APIs to integrate your payments. This way your application will always make it back within your flow before the payment is finalized, ensuring that you can run any code you want at that time. Keep in mind, though, that you may also need to deal with pending payments like e-checks or payment holds that could sometimes happen. In these cases you wouldn't want to deliver the item(s) until the payment clears, which would happen a few days later. As such, it's really best to use something IPN or Webhooks to automate post-transaction processing like this. However, that will not allow you to do it based on words on a page like you're wanting. If you're using IPN / Webhooks, though, you can build logic so that you activate the user only when their payment is indeed completed, so that should work for you I would think..??
... View more