0

I'm currently working on a website where users can purchase subscriptions using memberpress, I want to capture the user data after the signup process is completed and the payment transaction is also completed as well. If I add the member through dashboard manually I'm able to catch the user info as there is no payment gateway is involved, with this code

  function mepr_capture_new_member_added($event) {
    $user = $event->get_data();
    //mail('myemail', 'mp user added', 'new user added successfully');
  }
  add_action('mepr-event-member-added', 'mepr_capture_new_member_added');

As I'm new to WordPress development I don't know how I can access this data on my other page templates, that's why I'm sending an email to test if it works or not I was able to figure out the action hook for the transaction-completed event, but it doesn't seem to work properly. Here is the code

function mepr_capture_new_one_time_sub($event) {
    $transaction = $event->get_data();
    $user = $transaction->user();
    //mail('myemail', 'user purchased subscription', 'user-transaction-completed event captured '); }

add_action('mepr-event-non-recurring-transaction-completed', 'mepr_capture_new_one_time_sub');

I've read the complete memberpress documentation but the resources related to development are not what I'm looking for, they gave an option for webhooks and I can capture the data on zapier after user signup and payment transaction is completed but I need the data on my website so Zapier is not an option, they also provide the rest API but I want to capture the user information on 'signup and transaction complete' event and I don't think so that's possible with rest API, Please let me know how I can overcome this issue, any kind of help will be appreciated.

0

After searching for about 2 days I was able to figure out a way to capture the user after signup process is completed and the user's payment goes through the payment gateway, the way I'm doing it right now is when a signup process is completed user is redirected to thank-you page and a querystring containing subscr_id is passed on that page and I'm capturing that subscr_id and fetching the user from the database manually and its working perfectly fine, the process is seamless, and I can use the data on my other page templates as well.

You can simply get subscr_id from $_GET['subscr_id'] and use that to capture the user associated with this subscription from the table 'wp_mepr_subscriptions' and then use the user id to fetch the user detail from 'wp_usermeta' table of the wordpress, hope it helps someone else :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.