• Resolved pmProbeg

    (@pmprobeg)


    I’m having a very hard time dissecting the code here. I would like to be able to pass a custom variable into the system, and then have a new record be added to a custom table following a successful payment(whose name will also be passed into the payment system) with the data from the custom variable.

    What PHP page would I want to look at in order to get this done – I see around 30 pages here!

    Also, do I have the option to customize the table that PM Pro uses when a successful payment goes through? If so, what should I look for and in what script?

    Thanks a lot for any help!

    https://www.ads-software.com/extend/plugins/paid-memberships-pro/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jason Coleman

    (@strangerstudios)

    pmpProbeg (nice username),

    Not to push it too much, but a membership at https://www.paidmembershipspro.com would give you access to some documentation that would help you.

    That said, there is a “hook” in /preheaders/checkout.php that runs after a successful checkout.

    pmpro_after_checkout

    There is also pmpro_after_change_membership_level if you want to run code after the membership level changes for any reason (cancelations or admin sets it).

    The flow is basically preheaders/checkout.php is everything above the header on the checkout page and pages/checkout.php is everything within the checkout page. The page submits to itself to process and then redirects to /membership-confirmation/ (preheaders/confirmation.php, pages/confirmation.php).

    If you want to add fields to the checkout form, you can use one of these hooks:

    pmpro_checkout_after_level_cost
    pmpro_checkout_after_username
    pmpro_checkout_after_password
    pmpro_checkout_after_captcha
    pmpro_checkout_boxes

    Or templatize the whole page by copying pages/checkout.php to your theme and renaming it membership-checkout.php (you’ll have to remove the shortcode on the checkout page and add the page.php HTML around your template file).

    Hope this helps you. If you need more support, please sign up for a support account.

    Thread Starter pmProbeg

    (@pmprobeg)

    Alright, thank you for the help. I’m going to ask one more question, hopefully it’s a simple one to be answered.

    What exactly do you mean by a “hook”? I see it everywhere but I do not understand its purpose.

    Thanks,

    Your new #1 fan.

    Plugin Author Jason Coleman

    (@strangerstudios)

    Some reading RE hooks and filters:
    https://codex.www.ads-software.com/Plugin_API
    https://codex.www.ads-software.com/Plugin_API/Filter_Reference

    Basically it’s a bit of code like:

    do_action("my_hook")

    That WP places at certain parts of its code so you can “hook” into that spot and perform an action.

    And so if you write code like this:

    function my_hook_function()
    {
    ... do something ...
    }
    add_action("my_hook", "my_hook_function");

    It will do “something” at the point of the hook.

    Filters are basically the same thing, but you return a value with your function that alters a variable used in WP.

    Plugins like PMPro use this same system to allow you to interact at certain points… e.g. to do something after checkout or filter the list of countries.

    The examples and documentation on those WP pages is really good. Do some reading and try things out.

    Thread Starter pmProbeg

    (@pmprobeg)

    Thank you very much. I read both of the links you sent me and I have a strong understanding of hooks now. I see that you must first add_action and define the function’s name and then you must use “do_action” to call the hook itself.

    Now, when looking at your code I see “do_action(“pmpro_after_checkout”)” but I do not see ANYWHERE add_action(‘pmpro_after_checkout’) – I looked through all PHP files (nearly 50 of them it seems).

    Where on earth are you defining this function “pmpro_after_checkout”?

    If this is not important, I suppose I would want to add my own hook following this line:
    do_action(“pmpro_after_checkout”) to ensure that the payment went through – is that right?

    Thanks again for everything, making a lot more sense now.

    Plugin Author Jason Coleman

    (@strangerstudios)

    pmProbeg, I can’t continue this education for you further. You need to try some things out and learn a bit more.

    One last point to clear things up for you:

    The plugin author will write the do_action(…) line. This defines where the hook is run.

    The person who wants to use the hook (you) needs to write the add_action or add_filter line and the corresponding function to do what you need to do at that time.

    Thread Starter pmProbeg

    (@pmprobeg)

    OHH that clears it up, thanks so much!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Paid Memberships Pro] Insert into custom table’ is closed to new replies.