gpt4 book ai didi

wordpress - 以编程方式创建交易成员(member)

转载 作者:行者123 更新时间:2023-12-04 00:06:58 33 4
gpt4 key购买 nike

我在 github 上找到了以下代码段:

https://gist.github.com/supercleanse/8010675

    if(is_plugin_active('memberpress/memberpress.php')) {
add_action( 'user_register', 'mp_auto_enroll' );
//add_action( 'gform_user_registered', 'mp_auto_enroll', 10, 4 );

function mp_auto_enroll($user_id, $user_config=array(), $entry='', $user_pass='') {
$txn = new MeprTransaction();
$txn->user_id = $user_id;
$txn->product_id = 8; // TODO: Make sure you change this value to whatever the product_id will be
$txn->trans_num = uniqid();
$txn->status = MeprTransaction::$complete_str;
$txn->gateway = MeprTransaction::$free_gateway_str;
$txn->expires_at = 0; // 0 = Lifetime, null = product default expiration
$txn->store();
}
}

以上代码只添加了非循环交易,如何添加循环交易

我尝试添加

 $txn->amount = 100;

$txn->period_type="month";

它不起作用,请提供任何线索

最佳答案

以下代码有效,希望对其他人也有帮助。

            $sub = new MeprSubscription();
$sub->user_id = $user_ID;
$sub->product_id = 123;
$sub->price = 12.99;
$sub->total = 12.99;
$sub->period = 1;
$sub->period_type = 'months';
$sub->status = MeprSubscription::$active_str;
$sub_id = $sub->store();

$txn = new MeprTransaction();
$txn->amount = 12.99;
$txn->total = 12.99;
$txn->user_id = $user_ID;
$txn->product_id = 123;
$txn->status = MeprTransaction::$complete_str;
$txn->txn_type = MeprTransaction::$payment_str;
$txn->gateway = 'manual';
$txn->expires_at = gmdate('Y-m-d 23:59:59', (time() + MeprUtils::months(1)));
$txn->subscription_id = $sub_id;
$txn->store();

关于wordpress - 以编程方式创建交易成员(member),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38402603/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com