wordpress - programmatically create transaction memberpress -


i found following snippet on 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 change value whatever product_id         $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();       }     } 

above code adds non-recurring transaction, how add recurring transaction

i tried add

 $txn->amount = 100;   $txn->period_type="month"; 

its not working , clues please

the following code worked , hope helps else .

            $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(); 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -