WordPress.org

Ready to get started?Download WordPress

Forums

Paid Memberships Pro
[resolved] Insert into custom table (7 posts)

  1. pmProbeg
    Member
    Posted 2 years ago #

    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!

    http://wordpress.org/extend/plugins/paid-memberships-pro/

  2. strangerstudios
    Member
    Plugin Author

    Posted 2 years ago #

    pmpProbeg (nice username),

    Not to push it too much, but a membership at http://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.

  3. pmProbeg
    Member
    Posted 2 years ago #

    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.

  4. strangerstudios
    Member
    Plugin Author

    Posted 2 years ago #

    Some reading RE hooks and filters:
    http://codex.wordpress.org/Plugin_API
    http://codex.wordpress.org/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.

  5. pmProbeg
    Member
    Posted 2 years ago #

    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.

  6. strangerstudios
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  7. pmProbeg
    Member
    Posted 2 years ago #

    OHH that clears it up, thanks so much!!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic