function _buy_membership() { // system $system_obj = mgm_get_class('system'); $s_packs = mgm_get_class('subscription_packs'); $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails')); $dpne = bool_from_yn($system_obj->get_setting('disable_payment_notify_emails')); // get passthrough, stop further process if fails to parse $custom = $this->_get_transaction_passthrough($_POST['M_custom']); // local var extract($custom); // currency if (!$currency) { $currency = $this->setting['currency']; } // find user $user = get_userdata($user_id); //another_subscription modification if (isset($custom['is_another_membership_purchase']) && bool_from_yn($custom['is_another_membership_purchase'])) { $member = mgm_get_member_another_purchase($user_id, $custom['membership_type']); } else { $member = mgm_get_member($user_id); } // Get the current AC join date if (!($join_date = $member->join_date)) { $member->join_date = time(); } // Set current AC join date //if there is no duration set in the user object then run the following code if (empty($duration_type)) { //if there is no duration type then use Months $duration_type = 'm'; } // membership type default if (empty($membership_type)) { //if there is no account type in the custom string then use the existing type $membership_type = md5($member->membership_type); } // validate parent method $membership_type_verified = $this->_validate_membership_type($membership_type, 'md5|plain'); // verified if (!$membership_type_verified) { if (strtolower($member->membership_type) != 'free') { // notify admin, only if gateway emails on if (!$dge) { $message = 'Could not read membership type in the following POST data. Please debug or contact magic members to fix the problem making sure to pass on the following data. <br /><br /><pre>' . "\n\n" . print_r($_POST, true) . '</pre>'; mgm_mail($system_obj->setting['admin_email'], 'Error in WorldPay membership verification', $message); } // abort return; } else { $membership_type_verified = $member->membership_type; } } // set $membership_type = $membership_type_verified; // sub pack $subs_pack = $s_packs->get_pack($pack_id); // if trial on if ($subs_pack['trial_on']) { $member->trial_on = $subs_pack['trial_on']; $member->trial_cost = $subs_pack['trial_cost']; $member->trial_duration = $subs_pack['trial_duration']; $member->trial_duration_type = $subs_pack['trial_duration_type']; $member->trial_num_cycles = $subs_pack['trial_num_cycles']; } //pack currency over rides genral setting currency - issue #1602 if (isset($subs_pack['currency']) && $subs_pack['currency'] != $currency) { $currency = $subs_pack['currency']; } // duration $member->duration = $duration; $member->duration_type = strtolower($duration_type); $member->amount = $amount; $member->currency = $currency; $member->membership_type = $membership_type; $member->pack_id = $pack_id; // $member->payment_type = ($_POST['M_payment_type']=='subscription') ?'subscription' : 'one-time'; $member->active_num_cycles = isset($num_cycles) && !empty($num_cycles) ? $num_cycles : $subs_pack['num_cycles']; $member->payment_type = (int) $member->active_num_cycles == 1 ? 'one-time' : 'subscription'; /*// payment info for unsubscribe if(!isset($member->payment_info)) $member->payment_info = new stdClass; $member->payment_info->module = $this->code; if(isset($_POST['M_payment_type'])){ $member->payment_info->txn_type = $_POST['M_payment_type']; } if(isset($_POST['futurePayId'])){ $member->payment_info->subscr_id = $_POST['futurePayId']; } if(isset($_POST['transId'])){ $member->payment_info->txn_id = $_POST['transId']; }*/ // tracking fields module_field => post_field, will be used to unsubscribe $tracking_fields = array('txn_type' => 'M_payment_type', 'subscr_id' => 'futurePayId', 'txn_id' => 'transId'); // save tracking fields $this->_save_tracking_fields($tracking_fields, $member); // mgm transaction id $member->transaction_id = $_POST['M_custom']; // process PayPal response $new_status = $update_role = false; // errors $errors = array(); // transStatus switch ($_POST['transStatus']) { case "Y": $new_status = MGM_STATUS_ACTIVE; $member->status_str = __('Last payment was successful', 'mgm'); // old type match $old_membership_type = mgm_get_user_membership_type($user_id, 'code'); if ($old_membership_type != $membership_type) { $member->join_date = time(); // type join date as different var } // old content hide $member->hide_old_content = $hide_old_content; $time = time(); $last_pay_date = isset($member->last_pay_date) ? $member->last_pay_date : null; $member->last_pay_date = date('Y-m-d', $time); // THIS will cause double calculation /* ***********************************/ // check subscription_option if (isset($subscription_option)) { // on option switch ($subscription_option) { // @ToDo, apply expire date login case 'create': // expire date will be based on current time // expire date will be based on current time case 'upgrade': // expire date will be based on current time // already on top break; case 'downgrade': // expire date will be based on expire_date if exists, current time other wise // expire date will be based on expire_date if exists, current time other wise case 'extend': // expire date will be based on expire_date if exists, current time other wise // extend/expire date // calc expiry - issue #1226 // membership extend functionality broken if we try to extend the same day so removed && $last_pay_date != date('Y-m-d', $time) check if (!empty($member->expire_date)) { $expiry = strtotime($member->expire_date); if ($expiry > 0 && $expiry > $time) { $time = $expiry; } } break; } } /*************************************/ // type expanded $duration_exprs = $s_packs->get_duration_exprs(); // if not lifetime/date range if (in_array($member->duration_type, array_keys($duration_exprs))) { // take only date exprs //consider trial duration if trial period is applicable if (isset($trial_on) && $trial_on == 1) { //Do it only once if (!isset($member->rebilled) && isset($member->active_num_cycles) && $member->active_num_cycles != 1) { $time = strtotime("+{$trial_duration} {$duration_exprs[$trial_duration_type]}", $time); } } else { // time - issue #1068 $time = strtotime("+{$member->duration} {$duration_exprs[$member->duration_type]}", $time); } // formatted $time_str = date('Y-m-d', $time); // date extended if (!$member->expire_date || strtotime($time_str) > strtotime($member->expire_date)) { $member->expire_date = $time_str; } } else { //if lifetime: if ($member->duration_type == 'l') { // el = lifetime $member->expire_date = ''; } //issue #1096 if ($member->duration_type == 'dr') { // el = /date range $member->expire_date = $duration_range_end_dt; } } //update rebill: issue #: 489 if ($member->active_num_cycles != 1 && (int) $member->rebilled < (int) $member->active_num_cycles) { // rebill $member->rebilled = !$member->rebilled ? 1 : (int) $member->rebilled + 1; } //cancel previous subscription: //issue#: 565 $this->cancel_recurring_subscription($_POST['M_custom'], null, null, $pack_id); // role update if ($role) { $update_role = true; } // transaction_id $transaction_id = $this->_get_transaction_id('M_custom'); // hook args $args = array('user_id' => $user_id, 'transaction_id' => $transaction_id); // another membership if (isset($custom['is_another_membership_purchase']) && bool_from_yn($custom['is_another_membership_purchase'])) { $args['another_membership'] = $custom['membership_type']; } // after succesful payment hook do_action('mgm_membership_transaction_success', $args); // backward compatibility do_action('mgm_subscription_purchase_payment_success', $args); // new organized name break; case "C": $new_status = MGM_STATUS_NULL; $member->status_str = __('Last payment was refunded or denied', 'mgm'); // error $errors[] = $member->status_str; break; case "F": $new_status = MGM_STATUS_PENDING; $reason = 'Unknown'; $member->status_str = sprintf(__('Last payment is pending. Reason: %s', 'mgm'), $reason); // error $errors[] = $member->status_str; break; default: $new_status = MGM_STATUS_ERROR; $member->status_str = sprintf(__('Last payment status: %s', 'mgm'), $_POST['rawAuthMessage']); // error $errors[] = $member->status_str; break; } // old status $old_status = $member->status; // set new status $member->status = $new_status; // whether to acknowledge the user - This should happen only once $acknowledge_user = $this->send_payment_email($_POST['M_custom']); // whether to subscriber the user to Autoresponder - This should happen only once $acknowledge_ar = mgm_subscribe_to_autoresponder($member, $_POST['M_custom']); //another_subscription modification if (isset($custom['is_another_membership_purchase']) && bool_from_yn($custom['is_another_membership_purchase'])) { //issue #1227 if ($subs_pack['hide_old_content']) { $member->hide_old_content = $subs_pack['hide_old_content']; } mgm_save_another_membership_fields($member, $user_id); // Multiple membership upgrade: first time if (isset($custom['multiple_upgrade_prev_packid']) && is_numeric($custom['multiple_upgrade_prev_packid'])) { mgm_multiple_upgrade_save_memberobject($custom, $member->transaction_id); } } else { $member->save(); } // status change event do_action('mgm_user_status_change', $user_id, $new_status, $old_status, 'module_' . $this->module, $member->pack_id); //update coupon usage do_action('mgm_update_coupon_usage', array('user_id' => $user_id)); // role if ($update_role) { $obj_role = new mgm_roles(); $obj_role->add_user_role($user_id, $role); } // return action do_action('mgm_return_' . $this->module, array('user_id' => $user_id)); // backward compatibility do_action('mgm_return_subscription_payment_' . $this->module, array('user_id' => $user_id)); // new , individual do_action('mgm_return_subscription_payment', array('user_id' => $user_id, 'acknowledge_ar' => $acknowledge_ar, 'mgm_member' => $member)); // new, global: pass mgm_member object to consider multiple level purchases as well. // read member again for internal updates if any // another_subscription modification if (isset($custom['is_another_membership_purchase']) && bool_from_yn($custom['is_another_membership_purchase'])) { $member = mgm_get_member_another_purchase($user_id, $custom['membership_type']); } else { $member = mgm_get_member($user_id); } // transaction status mgm_update_transaction_status($member->transaction_id, $member->status, $member->status_str); // send email notification to client $blogname = get_option('blogname'); // on status switch ($member->status) { case MGM_STATUS_ACTIVE: //Sending notification email to user - issue #1468 if ($notify_user && $is_registration == 'Y') { $user_pass = mgm_decrypt_password($member->user_password, $user_id); do_action('mgm_register_user_notification', $user_id, $user_pass); } //sending upgrade notifaction email to admin if (isset($subscription_option) && $subscription_option == 'upgrade') { do_action('mgm_user_upgrade_notification', $user_id); } // init $subscription = ''; // add trial if ($subs_pack['trial_on']) { // trial $subscription = sprintf('%1$s %2$s for the first %3$s %4$s,<br> then ', $member->trial_cost, $member->currency, $member->trial_duration * $member->trial_num_cycles, $s_packs->get_pack_duration($subs_pack, true)); } // subject $subject = $system_obj->get_template('payment_success_email_template_subject', array('blogname' => $blogname), true); // on type if ($member->payment_type == 'subscription') { $payment_type = 'recurring subscription'; $subscription = sprintf('%1$s %2$s for each %3$s %4$s, %5$s', $member->amount, $member->currency, $member->duration, $s_packs->get_pack_duration($subs_pack), (int) $member->active_num_cycles > 0 ? sprintf('for %d installments', (int) $member->active_num_cycles) : 'until cancelled'); } else { $payment_type = 'one-time payment'; $subscription = sprintf('%1$s %2$s for %3$s %4$s', $member->amount, $member->currency, $member->duration, $s_packs->get_pack_duration($subs_pack)); } // body $message = $system_obj->get_template('payment_success_subscription_email_template_body', array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'payment_type' => $payment_type, 'subscription' => $subscription, 'admin_email' => $system_obj->setting['admin_email']), true); break; case MGM_STATUS_NULL: // subject $subject = $system_obj->get_template('payment_failed_email_template_subject', array('blogname' => $blogname), true); // message $message = $system_obj->get_template('payment_failed_email_template_body', array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'payment_type' => 'subscription payment', 'reason' => $member->status_str, 'admin_email' => $system_obj->setting['admin_email']), true); break; case MGM_STATUS_PENDING: // subject $subject = $system_obj->get_template('payment_pending_email_template_subject', array('blogname' => $blogname), true); // body $message = $system_obj->get_template('payment_pending_email_template_body', array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'reason' => $member->status_str, 'admin_email' => $system_obj->setting['admin_email']), true); break; case MGM_STATUS_ERROR: // subject $subject = $system_obj->get_template('payment_error_email_template_subject', array('blogname' => $blogname), true); // body $message = $system_obj->get_template('payment_error_email_template_body', array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'reason' => $member->status_str, 'admin_email' => $system_obj->setting['admin_email']), true); break; } // notify user if (!$dpne) { if ($acknowledge_user) { //issue #862 $subject = mgm_replace_email_tags($subject, $user_id); $message = mgm_replace_email_tags($message, $user_id); mgm_mail($user->user_email, $subject, $message); //update as email sent $this->update_paymentemail_sent($_POST['M_custom']); } } // send email notification to system administrator if (!$dge && $acknowledge_user) { $subject = "[{$blogname}] {$user->user_email} - {$member->status}"; $message = "\tUser display name: {$user->display_name}\n\n<br />\r\r\n\t\t\t\t\tUser email: {$user->user_email}\n\n<br />\r\r\n\t\t\t\t\tUser ID: {$user->ID}\n\n<br />\r\r\n\t\t\t\t\tMembership Type: {$membership_type}\n\n<br />\r\r\n\t\t\t\t\tNew status: {$member->status}\n\n<br />\r\r\n\t\t\t\t\tStatus message: {$member->status_str}\n\n<br />\r\r\n\t\t\t\t\tSubscription period: {$member->duration} " . $s_packs->get_pack_duration($subs_pack) . "\n\n<br />\r\r\n\t\t\t\t\tSubscription amount: {$member->amount} {$member->currency}\n<br />\r\r\n\t\t\t\t\tPayment Mode: {$member->payment_type}\n\n<br />\r\r\n\t\t\t\t\tPOST Data was: \n\n<br /><br /><pre>" . print_r($_POST, true) . '</pre>'; mgm_mail($system_obj->setting['admin_email'], $subject, $message); } // error condition redirect if (count($errors) > 0) { // mgm_redirect(add_query_arg(array('status'=>'error', 'errors'=>implode('|', $errors)), $this->_get_thankyou_url())); $this->_meta_redirect(add_query_arg(array('status' => 'error', 'errors' => implode('|', $errors)), $this->_get_thankyou_url())); } }
function _get_button_data($pack, $tran_id = NULL) { // system setting $system_obj = mgm_get_class('system'); $user_id = $pack['user_id']; $user = get_userdata($user_id); $member = mgm_get_member($user_id); //pack currency over rides genral setting currency - issue #1602 if (!isset($pack['currency']) || empty($pack['currency'])) { $pack['currency'] = $this->setting['currency']; } // setup data array $data = array('clientAccnum' => $this->setting['client_acccnum'], 'clientSubacc' => $this->setting['client_subacc']); // upgrade if ($this->setting['upgrade_api'] == 'upgrade' && ($pack['subscription_option'] == 'upgrade' || $pack['subscription_option'] == 'purchase_another')) { // encode $data['enc'] = $this->_create_upgrade_enc($pack, $data, $tran_id); } else { // merge // formname $formname = isset($pack['product']['ccbill_formname']) && !empty($pack['product']['ccbill_formname']) ? $pack['product']['ccbill_formname'] : $this->setting['formname']; // data $data = array_merge($data, array('formName' => $formname, 'language' => 'English', 'email' => $user->user_email)); // address fields $this->_set_address_fields($user, $data); // subscription purchase with ongoing/limited if (!isset($pack['buypost']) && isset($pack['duration_type'])) { // supports one-time recurring // if ($pack['num_cycles'] != 1 && isset($pack['duration_type']) ) { // old style // old functionality: using subscription id if (isset($pack['product']['ccbill_substype_id']) && !empty($pack['product']['ccbill_substype_id'])) { // format type id $typeid_fmt = str_pad(trim($pack['product']['ccbill_substype_id']), 10, '0', STR_PAD_LEFT); // iso currency $currency_iso = mgm_get_currency_iso4217($pack['currency']); // set $data['subscriptionTypeId'] = implode(':', array($typeid_fmt, $currency_iso)); $data['allowedTypes'] = $data['subscriptionTypeId']; } elseif (isset($this->setting['dynamic_pricing']) && $this->setting['dynamic_pricing'] == 'enabled') { // use dynamic pricing // vaidate $this->_valididate_dynamic_pricing(false); // types $intv_types = array('d' => 1, 'w' => 7, 'm' => 30, 'y' => 365); // currency $data['currencyCode'] = mgm_get_currency_iso4217($pack['currency']); // #1086 iso integer code code for currency // price $data['formPrice'] = number_format($pack['cost'], 2, '.', ''); //issue #1666 if (isset($pack['num_cycles']) && (int) $pack['num_cycles'] > 0) { $data['formPeriod'] = $intv_types[strtolower($pack['duration_type'])] * $pack['duration'] * $pack['num_cycles']; // 2;// in days } else { $data['formPeriod'] = $intv_types[strtolower($pack['duration_type'])] * $pack['duration']; } // trial if ($pack['trial_on']) { $data['formPrice'] = number_format($pack['trial_cost'], 2, '.', ''); $data['formPeriod'] = $intv_types[$pack['trial_duration_type']] * $pack['trial_duration'] * $pack['trial_num_cycles']; //in days } //issue #1739 if ($pack['num_cycles'] != 1) { // cost $data['formRecurringPrice'] = $data['formPrice']; $data['formRecurringPeriod'] = $intv_types[$pack['duration_type']] * $pack['duration']; //number of days $data['formRebills'] = isset($pack['num_cycles']) && (int) $pack['num_cycles'] > 0 ? (int) $pack['num_cycles'] : 99; // iteration(99=infinite) } $data['formDigest'] = md5($data['formPrice'] . $data['formPeriod'] . $data['formRecurringPrice'] . $data['formRecurringPeriod'] . $data['formRebills'] . $data['currencyCode'] . $this->setting['md5_hashsalt']); } // send mgm created username/password if ($this->setting['send_userpass'] == 'yes') { // username $data['username'] = $user->user_login; $data['password'] = mgm_decrypt_password($member->user_password, $user_id); } } else { // post purchase if (isset($this->setting['dynamic_pricing']) && $this->setting['dynamic_pricing'] == 'enabled') { // vaidate $this->_valididate_dynamic_pricing(false); // set price for addons $data['formPrice'] = $pack['cost']; // apply addons $this->_apply_addons($pack, $data, array('amount' => 'formPrice')); // price $data['formPrice'] = number_format($data['formPrice'], 2, '.', ''); $data['formPeriod'] = 2; // in days @todo manage via settings $data['currencyCode'] = mgm_get_currency_iso4217($pack['currency']); // #1086 iso integer code code for currency $data['formDigest'] = md5($data['formPrice'] . $data['formPeriod'] . $data['currencyCode'] . $this->setting['md5_hashsalt']); } } // custom passthrough $data['custom'] = $tran_id; } // update currency - issue #1602 /* if($pack['currency'] != $this->setting['currency']){ $pack['currency'] = $this->setting['currency']; }*/ // add filter @todo test $data = apply_filters('mgm_payment_button_data', $data, $tran_id, $this->module, $pack); // update pack/transaction mgm_update_transaction(array('data' => json_encode($pack), 'module' => $this->module), $tran_id); // return data return $data; }
$subject = "[" . $blogname . "] Admin Notification: Guest[IP: " . mgm_get_client_ip_address() . "] purchased post " . $post_id; $message = "Guest Purchase"; } mgm_mail($system_obj->setting['admin_email'], $subject, $message); } if (!$dge) { $message = 'Could not read membership type in the following POST data. Please debug or contact magic members to fix the problem making sure to pass on the following data. <br /><br /><pre>' . "\n\n" . print_r($_POST, true) . '</pre>'; // mail mgm_mail($system_obj->setting['admin_email'], 'Error in ' . ucwords($this->module) . ' membership verification', $message); } // on status switch ($member->status) { case MGM_STATUS_ACTIVE: //Sending notification email to user - issue #1468 if ($notify_user && $is_registration == 'Y') { $user_pass = mgm_decrypt_password($member->user_password, $user_id); do_action('mgm_register_user_notification', $user_id, $user_pass); } //sending upgrade notifaction email to admin if (isset($subscription_option) && $subscription_option == 'upgrade') { do_action('mgm_user_upgrade_notification', $user_id); } // init $subscription = ''; // add trial if ($subs_pack['trial_on']) { // trial $subscription = sprintf('%1$s %2$s for the first %3$s %4$s,<br> then ', $member->trial_cost, $member->currency, $member->trial_duration * $member->trial_num_cycles, $s_packs->get_pack_duration($subs_pack, true)); } // subject $subject = $system_obj->get_template('payment_success_email_template_subject', array('blogname' => $blogname), true);
function _buy_membership($transid = null) { // system $system_obj = mgm_get_class('system'); $s_packs = mgm_get_class('subscription_packs'); // get details //if transaction id is available: if (is_numeric($transid)) { $custom = $this->_get_transaction_passthrough($transid); extract($custom); // mgm_log($custom); } else { //Purchase Another Membership Level problem : issue #: 752 $is_another_membership_purchase = 'N'; $parts = explode('_', $_REQUEST['custom']); $params = array('user_id' => 0, 'duration' => '', 'duration_type' => '', 'pack_id' => 0, 'is_another_membership_purchase' => 'N', 'membership_type' => ''); $i = 0; foreach ($params as $param => $default) { if (isset($parts[$i])) { ${$param} = $parts[$i]; } else { ${$param} = $default; } $i++; } } // get pack $pack = $s_packs->get_pack($pack_id); // membership_type -issue #1005 if (empty($membership_type)) { $membership_type = $pack['membership_type']; } // user if ($user = get_userdata($user_id)) { //Purchase Another Membership Level problem : issue #: 752 if ($is_another_membership_purchase == 'Y') { // another_subscription modification //issue #1073 $member = mgm_get_member_another_purchase($user_id, $membership_type); } else { // get member $member = mgm_get_member($user_id); } //pack currency over rides genral setting currency - issue #1602 if (isset($pack['currency']) && !empty($pack['currency'])) { $currency = $pack['currency']; } else { $currency = $system_obj->setting['currency']; } // check //uncommented the below line as it is not updating in upgrade subscription //if (!$member->duration) { $member->duration = $duration ? $duration : 1; // one year $member->duration_type = $duration_type ? $duration_type : 'y'; $member->amount = 0.0; //$member->currency = 'USD';//not sure y hardcoded $member->currency = $currency; $member->membership_type = $membership_type; //} // set pack $member->pack_id = $pack_id; $member->active_num_cycles = isset($num_cycles) && !empty($num_cycles) ? $num_cycles : $pack['num_cycles']; // set status $member->status = MGM_STATUS_ACTIVE; $member->account_desc = __('Free Account', 'mgm'); $member->last_pay_date = ''; //reset payment_info if already set: if (isset($member->payment_info)) { unset($member->payment_info); } //unset rebill: if (isset($member->rebilled)) { unset($member->rebilled); } //unset transaction_id: if (isset($member->transaction_id)) { unset($member->transaction_id); } // join date $time = time(); // set if (!isset($member->join_date) || isset($member->join_date) && empty($member->join_date)) { $member->join_date = $time; } // old content hide - issue #1227 if (isset($hide_old_content)) { $member->hide_old_content = $hide_old_content; } // type expanded $duration_exprs = $s_packs->get_duration_exprs(); // if not lifetime/date range if (in_array($member->duration_type, array_keys($duration_exprs))) { // take only date exprs // @TODO, time should be last expire date #773, 3 use cases must be tracked // expect new param in tran subscription_type: new, upgrade, downgrade, extend $expire_date_ts = !$member->expire_date ? $time : strtotime($member->expire_date); // time $expire_date_ts = strtotime("+{$member->duration} {$duration_exprs[$member->duration_type]}", $expire_date_ts); // formatted $expire_date = date('Y-m-d', $expire_date_ts); // date extended if (!$member->expire_date || $expire_date_ts > strtotime($member->expire_date)) { $member->expire_date = $expire_date; } } else { //if lifetime: if ($member->duration_type == 'l') { // el = lifetime $member->expire_date = ''; } //issue #1096 if ($member->duration_type == 'dr') { // el = /date range $member->expire_date = $duration_range_end_dt; } } //Purchase Another Membership Level problem : issue #: 752 if (bool_from_yn($is_another_membership_purchase)) { $custom = array('is_another_membership_purchase' => 'Y'); } // old status $old_status = $member->status; // set new status $member->status = $new_status = MGM_STATUS_ACTIVE; // whether to subscriber the user to Autoresponder - This should happen only once //issue #1073 if (!empty($transid) && $transid != null) { $acknowledge_ar = mgm_subscribe_to_autoresponder($member, $transid); } else { $acknowledge_ar = mgm_subscribe_to_autoresponder($member, null); } // update if (isset($custom['is_another_membership_purchase']) && bool_from_yn($custom['is_another_membership_purchase'])) { // get object - issue #1227 $obj_sp = mgm_get_class('subscription_packs')->get($member->pack_id); if ($obj_sp['hide_old_content']) { $member->hide_old_content = $obj_sp['hide_old_content']; } mgm_save_another_membership_fields($member, $user_id); // Multiple membership upgrade: first time if ($transid && isset($custom['multiple_upgrade_prev_packid']) && is_numeric($custom['multiple_upgrade_prev_packid'])) { mgm_multiple_upgrade_save_memberobject($custom, $transid); } } else { // update $member->save(); } // on status - issue #1468 switch ($member->status) { case MGM_STATUS_ACTIVE: //sending notification email to user if ($notify_user && $is_registration == 'Y') { $user_pass = mgm_decrypt_password($member->user_password, $user_id); do_action('mgm_register_user_notification', $user_id, $user_pass); } break; } // status change event do_action('mgm_user_status_change', $user_id, $new_status, $old_status, 'module_' . $this->module, $member->pack_id); //update coupon usage do_action('mgm_update_coupon_usage', array('user_id' => $user_id)); // role if (isset($role)) { $obj_role = new mgm_roles(); $obj_role->add_user_role($user_id, $role); } // update pack/transaction if (is_numeric($transid)) { mgm_update_transaction(array('module' => $this->module, 'status_text' => __('Success', 'mgm')), $transid); } // return action do_action('mgm_return_' . $this->module, array('user_id' => $user_id)); // backward compatibility do_action('mgm_return_subscription_payment_' . $this->module, array('user_id' => $user_id)); // new , individual do_action('mgm_return_subscription_payment', array('user_id' => $user_id, 'acknowledge_ar' => $acknowledge_ar, 'mgm_member' => $member)); // new, global: pass mgm_member object to consider multiple level purchases as well. } }
/** * Send Email Notification to User on Membership Purchase * * @uses mgm_notify_user() * @param string $blogname * @param object $user * @param object $member * @param array $custom * @param array $subs_pack * @param object $s_packs * @param object $system_obj * @return bool $send */ function mgm_notify_user_membership_purchase($blogname, $user, $member, $custom, $subs_pack, $s_packs, $system_obj) { // local var extract($custom); // on status switch ($member->status) { case MGM_STATUS_ACTIVE: //Sending notification email to user - issue #1468 if (isset($notify_user) && isset($is_registration) && bool_from_yn($is_registration)) { // get pass $user_pass = mgm_decrypt_password($member->user_password, $user->ID); // action // send notification only once - issue #1601 if ($system_obj->setting['enable_new_user_email_notifiction_after_user_active'] == 'Y' && $notify_user) { //check - issue #1794 if (isset($member->transaction_id) && $member->transaction_id > 0) { $trans = mgm_get_transaction($member->transaction_id); $trans['data']['notify_user'] = false; mgm_update_transaction(array('data' => json_encode($trans['data'])), $member->transaction_id); } //notify do_action('mgm_register_user_notification', $user->ID, $user_pass); } } //sending upgrade notifaction email to admin if (isset($subscription_option) && $subscription_option == 'upgrade') { do_action('mgm_user_upgrade_notification', $user_id); } // init $subscription = ''; // add trial if (isset($subs_pack['trial_on']) && (int) $subs_pack['trial_on'] == 1) { // trial $subscription = sprintf('%1$s %2$s for the first %3$s %4$s,<br> then ', $member->trial_cost, $member->currency, $member->trial_duration * $member->trial_num_cycles, $s_packs->get_pack_duration($subs_pack, true)); } // on type if ($member->payment_type == 'subscription') { $payment_type = 'recurring subscription'; $subscription .= sprintf('%1$s %2$s for each %3$s %4$s, %5$s', $member->amount, $member->currency, $member->duration, $s_packs->get_pack_duration($subs_pack), (int) $member->active_num_cycles > 0 ? sprintf('for %d installments', (int) $member->active_num_cycles) : 'until cancelled'); } else { $payment_type = 'one-time payment'; $subscription .= sprintf('%1$s %2$s for %3$s %4$s', $member->amount, $member->currency, $member->duration, $s_packs->get_pack_duration($subs_pack)); } // subject $subject = $system_obj->get_template('payment_success_email_template_subject', array('blogname' => $blogname), true); // data $data = array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'payment_type' => $payment_type, 'subscription' => $subscription, 'admin_email' => $system_obj->get_setting('admin_email')); // message $message = $system_obj->get_template('payment_success_subscription_email_template_body', $data, true); break; case MGM_STATUS_NULL: // subject $subject = $system_obj->get_template('payment_failed_email_template_subject', array('blogname' => $blogname), true); // data $data = array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'payment_type' => 'subscription payment', 'reason' => $member->status_str, 'admin_email' => $system_obj->get_setting('admin_email')); // message $message = $system_obj->get_template('payment_failed_email_template_body', $data, true); break; case MGM_STATUS_PENDING: // subject $subject = $system_obj->get_template('payment_pending_email_template_subject', array('blogname' => $blogname), true); // data $data = array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'reason' => $member->status_str, 'admin_email' => $system_obj->get_setting('admin_email')); // body $message = $system_obj->get_template('payment_pending_email_template_body', $data, true); break; case MGM_STATUS_ERROR: // subject $subject = $system_obj->get_template('payment_error_email_template_subject', array('blogname' => $blogname), true); // data $data = array('blogname' => $blogname, 'name' => $user->display_name, 'email' => $user->user_email, 'reason' => $member->status_str, 'admin_email' => $system_obj->get_setting('admin_email')); // body $message = $system_obj->get_template('payment_error_email_template_body', $data, true); break; } // replace tags $subject = mgm_replace_email_tags($subject, $user->ID); $message = mgm_replace_email_tags($message, $user->ID); // return return @mgm_notify_user($user->user_email, $subject, $message); }
function _member_update_status(&$member, $user_id, $system_obj) { // return $return = array('old_status' => $member->status); // set new status $member->status = $return['new_status'] = mgm_post_var('upd_status'); // override_rebill_status_check $override_rebill_status_check = mgm_post_var('override_rebill_status_check'); // disable payment/rebill status check if (bool_from_yn($override_rebill_status_check)) { $member->last_payment_check = 'disabled'; } // active for manualpay if ($member->status == MGM_STATUS_ACTIVE) { // for manual pay if ($member->payment_info->module == 'mgm_manualpay') { // MARK status reset for manual pay upgrade $member->status_reset_on = NULL; // unset unset($member->status_reset_on); // mark as paid $member->status_str = __('Last payment was successful', 'mgm'); // send user notification: issue#: 537 if ($return['old_status'] == MGM_STATUS_PENDING) { // transaction status -issue #1287 mgm_update_transaction_status($member->transaction_id, $member->status, $member->status_str); // userdata $userdata = get_userdata($user_id); $blogname = get_option('blogname'); //issue #1263 if ($member->subscribed == 'Y') { do_action('mgm_return_subscription_payment', array('user_id' => $user_id, 'acknowledge_ar' => true, 'mgm_member' => $member)); } // subject $subject = $system_obj->get_template('payment_active_email_template_subject', array('blogname' => $blogname), true); // param $b_args = array('blogname' => $blogname, 'name' => mgm_stripslashes_deep($userdata->display_name), 'email' => $userdata->user_email, 'admin_email' => $system_obj->get_setting('admin_email')); // body $message = $system_obj->get_template('payment_active_email_template_body', $b_args, true); //issue #862 $subject = mgm_replace_email_tags($subject, $user_id); $message = mgm_replace_email_tags($message, $user_id); // mail mgm_mail($userdata->user_email, $subject, $message); //send an email to the buyer // send notification - issue #1758 if ($system_obj->setting['enable_new_user_email_notifiction_after_user_active'] == 'Y') { $user_pass = mgm_decrypt_password($member->user_password, $user_id); do_action('mgm_register_user_notification', $user_id, $user_pass); } // unset unset($userdata, $message); } } else { // mark as paid $member->status_str = __('Last rebill cycle processed manually', 'mgm'); } } // return return $return; }
/** * Process admin user add * * @param int $user_id * @return none */ function mgm_admin_user_register_process($user_id, $notify_user = false) { // get packs $pack = mgm_get_default_subscription_package(); //is admin $is_admin = is_admin(); // check if (isset($pack['id'])) { // system $system_obj = mgm_get_class('system'); // member $member = mgm_get_member($user_id); //issue #1602 if (!isset($pack['currency']) || empty($pack['currency'])) { $currency = $system_obj->setting['currency']; } else { $currency = $pack['currency']; } // if trial on if ($pack['trial_on']) { $member->trial_on = $pack['trial_on']; $member->trial_cost = $pack['trial_cost']; $member->trial_duration = $pack['trial_duration']; $member->trial_duration_type = $pack['trial_duration_type']; $member->trial_num_cycles = $pack['trial_num_cycles']; } // duration $member->duration = $pack['duration']; $member->duration_type = strtolower($pack['duration_type']); $member->active_num_cycles = $pack['num_cycles']; $member->amount = $pack['cost']; $member->currency = $currency; $member->membership_type = $pack['membership_type']; //$member->pack_id = $pack['pack_id']; //issue #1076 $member->pack_id = $pack['id']; // status $member->status = MGM_STATUS_ACTIVE; $member->status_str = __('Last payment was successful', 'mgm'); // join $member->join_date = time(); // old content hide $member->hide_old_content = $pack['hide_old_content']; // time $time = time(); // last pay date $member->last_pay_date = date('Y-m-d', $time); // expire if ($member->expire_date && $member->last_pay_date != date('Y-m-d', $time)) { // expiry $expiry = strtotime($member->expire_date); // greater if ($expiry > 0) { // time check if ($expiry > $time) { // update $time = $expiry; } } } // duration types expanded $duration_exprs = mgm_get_class('subscription_packs')->get_duration_exprs(); // time if (in_array($member->duration_type, array_keys($duration_exprs))) { // time $time = strtotime("+{$member->duration} {$duration_exprs[$member->duration_type]}", $time); // formatted $time_str = date('Y-m-d', $time); // date extended if (!$member->expire_date || strtotime($time_str) > strtotime($member->expire_date)) { // This is to make sure that expire date is not copied from the selected members if any $member->expire_date = $time_str; } } //user pass $user_password = mgm_decrypt_password($member->user_password, $user_id); // save $member->save(); //after active if ($notify_user) { mgm_new_user_notification($user_id, $user_password, $is_admin ? false : true); } } // return return $user_id; }
function _get_button_data($pack, $tran_id = NULL) { // system $system_obj = mgm_get_class('system'); $user_id = $pack['user_id']; $user = get_userdata($user_id); // item $item = $this->get_pack_item($pack); // set data $data = array('co_code' => $this->setting['co_code'], 'pi_code' => isset($pack['product']['epoch_product_code']) ? $pack['product']['epoch_product_code'] : '', 'reseller' => $this->setting['reseller'], 'product_description' => $item['name'], 'response_post' => 'Y', 'pi_returnurl' => $this->setting['return_url'], 'email' => $user->user_email); // address fields $this->_set_address_fields($user, $data); // username/password if ($this->setting['send_userpass'] == 'yes') { $data['username'] = $user->user_login; $data['password'] = mgm_decrypt_password(mgm_get_member($user_id)->user_password, $user_id); } else { $data['no_userpass'] = 1; $data['no_userpassverify'] = 1; } // custom passthrough $data['x_custom'] = $tran_id; // passthrough field prefixed with x_ // add filter @todo test $data = apply_filters('mgm_payment_button_data', $data, $tran_id, $this->module, $pack); // update pack/transaction mgm_update_transaction(array('data' => json_encode($pack), 'module' => $this->module), $tran_id); // return data return $data; }
function _buy_membership($transid = null) { // packs $s_packs = mgm_get_class('subscription_packs'); // get details //if transaction id is available: if (is_numeric($transid)) { $custom = $this->_get_transaction_passthrough($transid); extract($custom); } else { list($user_id, $duration, $duration_type, $pack_id) = explode('_', $_REQUEST['custom']); //mgm_log($_REQUEST['custom']); } // get pack $pack = $s_packs->get_pack($pack_id); // membership_type $membership_type = $pack['membership_type']; // check if ($user = get_userdata($user_id)) { // get member $member = mgm_get_member($user_id); // check if (!$member->duration) { $member->duration = $duration ? $duration : 1; // one year $member->duration_type = $duration_type ? $duration_type : 'y'; $member->amount = 0.0; $member->currency = isset($pack['currency']) && !empty($pack['currency']) ? $pack['currency'] : 'USD'; $member->membership_type = $membership_type; } // set pack $member->pack_id = $pack_id; $member->active_num_cycles = isset($num_cycles) && !empty($num_cycles) ? $num_cycles : $subs_pack['num_cycles']; // set status $member->status = MGM_STATUS_ACTIVE; $member->account_desc = __('Trial Account', 'mgm'); $member->last_pay_date = ''; // join date $time = time(); // type expanded $duration_exprs = $s_packs->get_duration_exprs(); // if not lifetime/date range if (in_array($member->duration_type, array_keys($duration_exprs))) { // take only date exprs // time $time = strtotime("+{$member->duration} {$duration_exprs[$member->duration_type]}", $time); // formatted $time_str = date('Y-m-d', $time); // date extended if (!$member->expire_date || strtotime($time_str) > strtotime($member->expire_date)) { $member->expire_date = $time_str; } } else { //if lifetime: if ($member->duration_type == 'l') { // el = lifetime $member->expire_date = ''; } //issue #1096 if ($member->duration_type == 'dr') { // el = /date range $member->expire_date = $duration_range_end_dt; } } // whether to subscriber the user to Autoresponder - This should happen only once $acknowledge_ar = mgm_subscribe_to_autoresponder($member, $transid); // update $member->save(); // on status - issue #1468 switch ($member->status) { case MGM_STATUS_ACTIVE: //sending notification email to user if ($notify_user && $is_registration == 'Y') { $user_pass = mgm_decrypt_password($member->user_password, $user_id); do_action('mgm_register_user_notification', $user_id, $user_pass); } break; } // role if (isset($role)) { $obj_role = new mgm_roles(); $obj_role->add_user_role($user_id, $role); } // update pack/transaction if (is_numeric($transid)) { mgm_update_transaction(array('module' => $this->module, 'status_text' => __('Success', 'mgm')), $transid); } // return action do_action('mgm_return_' . $this->module, array('user_id' => $user_id)); //issue#: 343 do_action('mgm_unpaid_autoresponder', array('user_id' => $user_id)); // autoresponder do_action('mgm_return_subscription_payment_' . $this->module, array('user_id' => $user_id)); // //issue#: 666 do_action('mgm_return_subscription_payment', array('user_id' => $user_id, 'acknowledge_ar' => $acknowledge_ar, 'mgm_member' => $member)); // new, global: pass mgm_member object to consider multiple level purchases as well. } }
/** * process facebook login * * @param none * @return mixed/object error */ function mgm_process_facebook_login() { // system $system_obj = mgm_get_class('system'); // lib @(require_once MGM_LIBRARY_DIR . 'third_party/facebook/facebook.php'); // fb object $facebook = new Facebook(array('appId' => $system_obj->setting['facebook_id'], 'secret' => $system_obj->setting['facebook_key'])); // get user if ($fbuser = $facebook->getUser()) { // try try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { $user_profile = ''; } // check if (!empty($user_profile)) { # User info ok? Let's print it (Here we will be adding the login and registering routines) if (isset($user_profile['email']) && !empty($user_profile['email'])) { // user $user = get_user_by('email', $user_profile['email']); // check if ($user->ID) { // member $member = mgm_get_member($user->ID); // login $user_login = $user->data->user_login; // pass $password = $member->user_password; // desc pass $password = mgm_decrypt_password($password, $user->ID, $member->rss_token); // process login mgm_process_user_login('login', $user_login, $password); } } } } // error, email did not match $errors = new WP_Error(); // url $register_url = mgm_get_custom_url('register'); // email $fb_email = isset($user_profile['email']) ? $user_profile['email'] : 'n/a'; // add error $errors->add('invalid_facebook_user', sprintf(__('<strong>ERROR</strong>: Your Facebook Account "%s" should be linked to your %s Account. Please Register here <a href="%s" target="_blank">%s</a> to avail Facebook Connect', 'mgm'), $fb_email, get_bloginfo('name'), $register_url, get_bloginfo('name'))); // return if ($errors->get_error_code()) { return $errors; } }
/** * Replace email short tags with contnet * * @param string $message and $user_id * @return string $message */ function mgm_replace_email_tags($message, $user_id = NULL) { global $wpdb; // has user if (!$user_id) { // cusrrent user $current_user = wp_get_current_user(); // set $user_id = $current_user->ID; } else { // get user $current_user = new WP_User($user_id); } // mgm member $member = mgm_get_member($user_id); $system_obj = mgm_get_class('system'); // user if ($user_id > 0) { // display name if (isset($current_user->first_name) && !empty($current_user->first_name)) { $name = $current_user->first_name; } elseif (isset($member->custom_fields->first_name) && !empty($member->custom_fields->first_name)) { $name = $member->custom_fields->first_name; } else { $name = $current_user->display_name; } //first name if (isset($member->custom_fields->first_name) && !empty($member->custom_fields->first_name)) { $first_name = $member->custom_fields->first_name; } //last name if (isset($member->custom_fields->last_name) && !empty($member->custom_fields->last_name)) { $last_name = $member->custom_fields->last_name; } //user name $username = $current_user->user_login; //password $password = mgm_decrypt_password($member->user_password, $user_id); //client email $email = $current_user->user_email; //reason email $reason = $member->status_str; //expire_date $expire_date = $member->expire_date; //just fetch the key from db as it is already updated $key = $current_user->user_activation_key; //passwordlink $passwordlink = network_site_url("wp-login.php?action=rp&key={$key}&login=" . rawurlencode($username), 'login'); //amount email -#issue 1069 $amount = $member->amount; //membership_type email $membership_type = $member->membership_type; } //admin_email $admin_email = $system_obj->get_setting('admin_email'); // blog name $blogname = get_option('blogname'); // siteurl name $siteurl = network_site_url(); //login_url $login_url = wp_login_url(); //loginurl $loginurl = mgm_get_custom_url('login'); // issue #1177 $currency_sign = mgm_get_currency_symbols($system_obj->setting['currency']); //email short tags array $tags = array('name', 'username', 'password', 'login_url', 'admin_email', 'email', 'blogname', 'siteurl', 'loginurl', 'reason', 'expire_date', 'passwordlink', 'first_name', 'last_name', 'amount', 'membership_type', 'currency_sign'); // loop foreach ($tags as $tag) { // check if (!isset(${$tag})) { ${$tag} = ''; } // set $message = str_replace('[' . $tag . ']', ${$tag}, $message); } // return return $message; }
/** * custom user login form, output by [user_register] shortcode * * @param bool $use_default_links * @param string $html */ function mgm_user_login_form($use_default_links = true) { //fb logins i.e. facebook connect errors global $fb_errors; // hide from logged in user if (is_user_logged_in()) { // not logout call to self if (mgm_get_var('action', '', true) != 'logout') { return __('You are already logged in!', 'mgm'); } } // check auto login if ($html = mgm_try_auto_login()) { return $html; } // init errors $fb_errors = $errors = null; // system $system_obj = mgm_get_class('system'); // process hooked logins i.e. facebook connect do_action('mgm_user_login_pre_process'); // check security before processing form if (isset($_POST['log'])) { if (!wp_verify_nonce(mgm_post_var('_mgmnonce_user_login'), 'user_login')) { mgm_security_error('user_login'); } } // issue #1203 if (empty($fb_errors)) { $errors = mgm_process_user_login(); } else { $errors = $fb_errors; } // action $form_action = mgm_get_custom_url('login'); // init $user_login = $user_pwd = $html = ''; //check logged in cookie: $rememberme = !empty($_POST['rememberme']); $interim_login = isset($_REQUEST['interim-login']); // login if (isset($_POST['log'])) { $user_login = esc_attr(stripslashes($_POST['log'])); // issue# 525 } elseif ($cookie_userid = wp_validate_auth_cookie('', 'logged_in')) { //check a valid logged cookie exists // cookie $arr_loggedin_cookie = wp_parse_auth_cookie('', 'logged_in'); // get mgm_member $member = mgm_get_member($cookie_userid); // mark checked $rememberme = true; // get login from cookie $user_login = esc_attr(stripslashes($arr_loggedin_cookie['username'])); // password from member object // issue#: 672 $user_pwd = mgm_decrypt_password($member->user_password, $cookie_userid); } // redirect $redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''; // start html $html = ''; // set error ! if (isset($errors) && is_object($errors)) { // get error if ($error_html = mgm_set_errors($errors, true)) { $html .= $error_html; } } // check if (bool_from_yn($system_obj->get_setting('enable_email_as_username'))) { $email_username_label = __('Email', 'mgm'); } else { $email_username_label = __('Username', 'mgm'); } // start form $html .= '<form class="mgm_form" name="loginform" id="loginform" action="' . $form_action . '" method="post"> <div> <label>' . $email_username_label . '<br /> <input type="text" name="log" id="user_login" class="input" value="' . esc_attr($user_login) . '" size="40" tabindex="10" /></label> </div> <div> <label>' . __('Password', 'mgm') . '<br /> <input type="password" name="pwd" id="user_pass" class="input" value="' . esc_attr($user_pwd) . '" size="40" tabindex="20" /></label> </div>'; //Issue #782 $html .= mgm_get_captcha_field('mgm_login_field'); // login form, fetch as return // do_action('login_form'); // custom $html .= apply_filters('mgm_login_form', $html); // forget $html .= '<div class="forgetmenot"> <label> <input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" ' . checked($rememberme, true, false) . ' /> ' . __('Remember Me', 'mgm') . ' </label> </div>'; // buttons $buttons = array(sprintf('<input class="button mgm-login-button" type="submit" name="wp-submit" id="wp-submit" value="%s" tabindex="100" />', __('Log In', 'mgm'))); // apply filters $buttons_s = implode(apply_filters('mgm_login_form_buttons_sep', ' '), apply_filters('mgm_login_form_buttons', $buttons)); // append $html .= sprintf('<div class="login-page-buttons">%s</div>', $buttons_s); if ($system_obj->get_setting('disable_testcookie') == 'N') { // hiddens $html .= '<input type="hidden" name="testcookie" value="1" /> '; } // intrim if ($interim_login) { $html .= '<input type="hidden" name="interim-login" value="1" />'; } else { $html .= '<input type="hidden" name="redirect_to" value="' . esc_attr($redirect_to) . '" />'; } // nonce $html .= wp_nonce_field('user_login', '_mgmnonce_user_login', true, false); // end form $html .= '</form>'; // after links $links = array(); // interim_login if (!$interim_login) { // check mail will not have any if (!isset($_GET['checkemail']) || isset($_GET['checkemail']) && !in_array($_GET['checkemail'], array('confirm', 'newpass'))) { // register if (get_option('users_can_register')) { $links[] = sprintf('<a class="mgm-register-link" href="%s">%s</a>', mgm_get_custom_url('register'), __('Register', 'mgm')); } // lostpassword $links[] = sprintf('<a class="mgm-lostpassword-link" href="%s" title="%s">%s</a>', mgm_get_custom_url('lostpassword'), __('Password Lost and Found', 'mgm'), __('Lost your password?', 'mgm')); } } // apply filters $links_s = implode(apply_filters('mgm_login_form_after_links_sep', ' | '), apply_filters('mgm_login_form_after_links', $links)); // appaend $html .= sprintf('<div class="login-page-links">%s</div>', $links_s); // scripts & styles -------------------- // focus $focus = $user_login || $interim_login ? 'user_pass' : 'user_login'; // script $script = 'function wp_attempt_focus(){setTimeout( function(){ try{ d = document.getElementById("' . $focus . '"); d.focus();} catch(e){}}, 200);}'; // focus if (@(!$error)) { $script .= 'wp_attempt_focus();'; } // script $script = sprintf('<script type="text/javascript">%s</script>', apply_filters('mgm_login_form_inline_script', $script)); // scripts $html .= apply_filters('mgm_login_form_scripts', $script); // style $style = '.login-page-links, .login-page-buttons{margin-top:10px; clear:both}'; // style $style = sprintf('<style type="text/css">%s</style>', apply_filters('mgm_login_form_inline_style', $style)); // style $html .= apply_filters('mgm_login_form_styles', $style); // apply filters and return return apply_filters('mgm_login_form_html', $html); }