• I have a sales page with a time-sensitive offer on one of my wordpress posts. The idea is that the first person that comes to the page and buys first gets the product.

    Therefore when charge succeeded event in Stripe (payment processor) is triggered, I want the sales page to be redirected to a “sorry it is too late” page. I am using the gravity forms + stripe plugin.

    So for example, I have a page called sales page. It is available for 3 days.

    1 day into the sale someone comes along and buys the product.

    If someone else comes to the sales page after the product has been purchased, I want it to go to a too late page.

    Here is the code I have created. test key in the code is fake for posting purposes. I think I am missing some wordpress hook in my code.

    https://pastebin.com/aiqCk4tt

    I use a value in custom field suite plugin meta box on the post as the too late trigger.

    When the value is set to 1, the page disappears.

    When it is zero, the page is available and the product can still be purchased.

    The problem is I am not sure where to put the code. Because when I add it to my theme’s functions.php it says fatal error called to undefined function add_action()

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    functions.php should be an acceptable place to put init hook code, the error you are getting is quite odd. It usually happens when non-wordpress files are requested directly, which call wordpress functions, but without going through the usual wordpress parsing system.

    You might try making your code into a basic plugin by adding the appropriate comment header data to the file and storing it in a folder under wp-content/plugins/, then activating it. There’s a good chance this will not help, but I don’t know what else to suggest.

Viewing 1 replies (of 1 total)
  • The topic ‘Where Do I Place This Code?’ is closed to new replies.