Which hook can capture $_REQUEST[] in direct payment link

Since Membership 2 doesn't support dual site memberships yet for multisite wordpress installations, I need to capture a URI component passed in button link from a particular blog in the our multisite installation and then be able to store this and applied to the invoice. This will help us sort invoices, and tell us which blog the membership belongs to. Currently the Membership 2 plugin is picking a random blog for email transmissions either a completed payment or cancellation. Also, canned email responses, only the main blog email can be selected. When is the release date for allowing the main blog to host site wide memberships, and also the individual blogs?

  • Adam Czajczyk

    Hello Zachary,

    I hope you're well today and thank you for your question!

    I'm not sure however if I'm getting this right. The Membership 2 Pro can work on per-site or network-wide base in Multisite environment. On "per-site" setup it acts indeed as a separate membership plugin for each site however on "network wide" setup you can manage all memberships centrally. If you add this line to your "wp-config.php" file

    define( 'MS_PROTECT_NETWORK', true );

    you'll be able to create protection rules for all the sites and also manage billings/members/invoices etc centrally.

    Woudn't that work for you? Could you provide me with a simple "case scenario" referring to your setup?

    I'm asking this only to get a clearer picture of what you wish to achieve and understand better what exactly should I ask plugin's developer in case some additional code would indeed be necessary.

    Please advise!

    Best regards,

    • Zachary

      Hi Adam!

      Thanks for your reply. We are aware of the network-wide setting, and currently we are using the plugin network protect mode. Our key focus of our project is to allow all blogs in our multi-site installation to attract users to subscribe to a network wide membership. Each blog will be credited for the referral to the membership. At this time, we are unsure or may be unaware how to successfully store (during payment) the blog name or blog ID on the invoice so we know how to credit each blog for the referral. I don't believe the plugin in it's default form does this.

      We are looking for a solution/workaround via the URI to capture the blog name or blog ID than can be passed to the plugin from each blog, so the plugin knows which blog the membership originated from.

      For instance.

      Currently in network protect mode, the plugin is randomly selecting a blog id/name in the cancellation email. How do we statically set the blog referrer in the plugin via a URI component is the main question.

      We understand that the plugin cannot operate in both modes currently. But we are looking for a solution temporarily until the plugin is released with network membership and individual blog membership simultaneous capability.

      Thank you for your time.

  • Adam Czajczyk

    Hello Zachary,

    Thank you for your response.

    I've just talked to one of Membership 2 Pro developers. He'll be happy to suggest some solution for you and he confirmed that we're open for adding some more hooks to the plugin if necessary but still we'd need a bit more detailed description of what exactly would you like to achieve.

    I do understand the main goal however it would be great if you could additionally provide me with an example "case scenario" and/or step-by-step guide on how that setup should work.

    Please advise and I'll then consult this again with the developer.

    Best regards,

  • Zachary

    Hi Adam!

    Thanks for responding...

    Currently a page template designed in one of our blog's theme is checking membership status, and decides to display content based upon if the particular logged in user has access to the membership or not. If not, a buy link button is generated with the relative membership id below: (Obviously in Network Protect Mode, this link references the main blog url, the designated plugin register page, along with the correct membership id in the URI.)


    After a successful transaction, a m2-registration-complete-5372.php template redirects the user back to the relative page template which will now re-check access, and provide the content.

    What we need to do in this process, the membership above that is purchased by the user, we need to reference the site_url(); or blog_id(); to be injected into the saved key array in the relationship data. When referencing the invoice for this particular transaction, we can see which blog the buy link was generated from, and be able to sort the invoices by this stored attribute on the invoice. We can capture the blog information by sending along an additional URI in the URL string as referenced below quite easily from our page template:



    I hope this clarifies what needs done, and it is quite simple to accomplish. We just need to know the appropriate hook to inject the $_REQUEST['blogid'] OR $_REQUEST['referenceurl'] so that it is recorded in the array of variables of the membership relationship ID. Even for the time being if we have to use PhpMyAdmin or MYSQL to query the appropriate membership table data based upon the stored blog reference in the data. We will then know how to direct compensation to our blogs "affiliates" on our payable schedule.


  • Adam Czajczyk

    Hello Zach,

    Thank you for this explanation. That's much clearer now.

    Let me please ask one of Membership 2 Pro developers for a little help here and hopefully we'll be able to provide you with useful information on this in no time.

    Please not however that his response time may be a bit longer than mine here on support forum as he deals with a lot of complex issues on daily basis. I did however contacted him via our internal chat and will try to get an answer for your as soon as possible.

    Please keep an eye on this thread fur further information!

    Best regards,

  • Adam Czajczyk

    Hello Zach!

    I just spoke with one of our developers that's engaged with Membership 2 Pro. It seems that it wouldn't be an easy task to interact with invoices here and may require some changes to plugin's code. He suggested a kind of "workaround" though.

    As your goal is to track signups to get to know which "blog" referred a member and you already do have a way (I hope I understood that right) to

    - add blog id to signup link
    - capture that blog id (e.g. from "$_REQUEST[ ]")

    the solution may be to first store that id as a session variable


    and then hook up to


    This is triggered right after the member paid for his/her members (this may be an initial payment or a payment automatically triggered by subscription created in payment processor system).

    Your custom code hooked to that event would then read "blog_id" from stored session, delete session variable (as it's no longer necessary) and then store e.g. that blog ID along with a user ID (and e.g. membership ID, date etc) with a custom table.

    That's quite a bit of custom coding but this way you should be able to get to know who signed up for which membership, referred by which blog and when - including when a payment was made.

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.