Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Help me finish this php code for Memberpress site WordPress


I am working on a site with Memberpress. I use gravity forms/gravity press for registration. The client requires a different expiry date than what Memberpress creates by default. So, I have set up the form to calculate a new date and save it in wp_usermeta (default spot for the gravity forms registration addon).

I am trying to write code to run when a transaction is finished that will grab the modified date from wp_usermeta and insert is in the most recent transaction for that user. I am pasting below what I have so far. Can you please help me finish this code?

function mepr_capture_completed_transaction($event) {
$transaction = $event->get_data();
$user = $transaction->user();

if(($subscription = $transaction->subscription_id)) {
$subscription_number = $subscription->subscr_id;
//This transaction belongs to a recurring subscription
else {
$transaction_number = $transaction->trans_num;
//This is a non-recurring transaction

global $wpdb;

$newdate = mysql_result(mysql_query("SELECT yearFromNow FROM usermeta WHERE userid = ".$user. "and meta_key = 'mepr_mepr_yearfromnow' " ), 0);

$insertdate = mysql_result(mysql_query("INSERT into wp_mepr_transactions max(expires_at) value ".$newdate." into WHERE userid = ".$user ), 0);

add_action('mepr-event-transaction-completed', 'mepr_capture_completed_transaction');

Answers (0)

No answers yet.