Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1391804
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionI'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.
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionI'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.
Share Improve this question asked Apr 25, 2019 at 12:16 RBDRBD 211 silver badge4 bronze badges2 Answers
Reset to default 1After 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 :)
You can get the user by using the action mepr-txn-status-complete
which fires on a successful transaction. If you need to, you can use a custom meta field to check whether or not this is the first time you have run this function against this user. This belongs in your theme's function file or in your custom plugin.
function capture_completed_transaction($txn) {
$subscription = $txn->subscription();
// Ensure the subscription is legit
if($subscription === false) { return; }
// Use any of the following objects to interact with as needed
$user = new MeprUser($txn->user_id); //A MeprUser object
$membership = new MeprProduct($txn->product_id); //A MeprProduct object
$users_memberships = $user->active_product_subscriptions('ids'); //An array of membership CPT ID's
$current_user = new WP_User($txn->user_id);
if ( ! $current_user->exists() ) {
return;
}
}
add_action('mepr-txn-status-complete', 'capture_completed_transaction');
MemberPress' documentation is sadly lacking, after much frustration I found this helpful gist: MemberPress Subscription Actions
本文标签: pluginsHow can I capture Memberpress user info after signup
版权声明:本文标题:plugins - How can I capture Memberpress user info after signup 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744765634a2624021.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论