public function mailNewApproveAffiliate($user_id, $user_pass) { add_filter('wp_mail_from', array($this, 'filterMailAddress')); add_filter('wp_mail_from_name', array($this, 'filterMailName')); $user = get_user_by('id', $user_id); $username = $user->user_login; $address = $user->user_email; $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $login_url = get_option(WPAM_PluginConfig::$AffLoginPageURL); //wp_login_url(); $subject = "Affiliate Application for " . $blogname; //$message = "New affiliate registration for {blogname}: has been approved!. \n\nUsername: {affusername} \nPassword: {affpassword} \nLogin URL: {affloginurl}"; $message = WPAM_MessageHelper::GetMessage('affiliate_application_approved_email'); $tags = array("{blogname}", "{affusername}", "{affpassword}", "{affloginurl}"); $vals = array($blogname, $username, $user_pass, $login_url); $body = str_replace($tags, $vals, $message); WPAM_Logger::log_debug($subject); WPAM_Logger::log_debug("Sending an email to " . $address); $mail_sent = wp_mail($address, $subject, $body); if ($mail_sent == true) { WPAM_Logger::log_debug("Email was sent successfully by WordPress"); } else { WPAM_Logger::log_debug("Email could not be sent by WordPress"); } remove_filter('wp_mail_from', array($this, 'filterMailAddress')); remove_filter('wp_mail_from_name', array($this, 'filterMailName')); }
public function processRequest($request) { $db = new WPAM_Data_DataAccess(); $affiliateFields = $db->getAffiliateFieldRepository()->loadMultipleBy(array('enabled' => true), array('order' => 'asc')); if (isset($request['action']) && $request['action'] == 'submit') { $form_validated = false; $affiliateHelper = new WPAM_Util_AffiliateFormHelper(); $vr = $affiliateHelper->validateForm(new WPAM_Validation_Validator(), $request, $affiliateFields); if ($vr->getIsValid()) { $form_validated = true; } $output = apply_filters('wpam_validate_registration_form_submission', '', $request); if (!empty($output)) { $form_validated = false; } if ($form_validated) { $model = $affiliateHelper->getNewAffiliate(); $affiliateHelper->setModelFromForm($model, $affiliateFields, $request); //Fire the action hook do_action('wpam_front_end_registration_form_submitted', $model, $request); //Check if automatic affiliate approval option is enabled if (get_option(WPAM_PluginConfig::$AutoAffiliateApproveIsEnabledOption) == 1) { $userHandler = new WPAM_Util_UserHandler(); $userHandler->AutoapproveAffiliate($model); return new WPAM_Pages_TemplateResponse('aff_app_submitted_auto_approved'); } //Do the non auto approval process $db = new WPAM_Data_DataAccess(); $id = $db->getAffiliateRepository()->insert($model); if ($id == 0) { if (WPAM_DEBUG) { echo '<pre>', var_export($model, true), '</pre>'; } wp_die(__('Error submitting your details to the database. This is a bug, and your application was not submitted.', 'affiliates-manager')); } $mailer = new WPAM_Util_EmailHandler(); //Notify admin that affiliate has registered $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = sprintf(__('New affiliate registration on your site %s:', 'affiliates-manager'), $blogname) . "\r\n\r\n"; $message .= sprintf(__('Name: %s %s', 'affiliates-manager'), $request['_firstName'], $request['_lastName']) . "\r\n"; $message .= sprintf(__('Email: %s', 'affiliates-manager'), $request['_email']) . "\r\n"; $message .= sprintf(__('Company: %s', 'affiliates-manager'), $request['_companyName']) . "\r\n"; $message .= sprintf(__('Website: %s', 'affiliates-manager'), $request['_websiteUrl']) . "\r\n\r\n"; $message .= sprintf(__('View Application: %s', 'affiliates-manager'), admin_url('admin.php?page=wpam-affiliates&viewDetail=' . $id)) . "\r\n"; $mailer->mailAffiliate(get_option('admin_email'), __('New Affiliate Registration', 'affiliates-manager'), $message); //Notify affiliate of their application $affsubj = sprintf(__('Affiliate application for %s', 'affiliates-manager'), $blogname); $affmessage = WPAM_MessageHelper::GetMessage('affiliate_application_submitted_email'); $mailer->mailAffiliate($request['_email'], $affsubj, $affmessage); return new WPAM_Pages_TemplateResponse('affiliate_application_submitted'); } else { return $this->getForm($affiliateFields, $request, $vr); } } //else return $this->getForm($affiliateFields); }
public function declineApplication($affiliateId) { if (!wp_get_current_user()->has_cap(WPAM_PluginConfig::$AdminCap)) { throw new Exception(__('Access denied.', 'affiliates-manager')); } $affiliateId = (int) $affiliateId; $db = new WPAM_Data_DataAccess(); $affiliate = $db->getAffiliateRepository()->load($affiliateId); if ($affiliate === null) { throw new Exception(__('Invalid affiliate', 'affiliates-manager')); } if ($affiliate->isPending() || $affiliate->isBlocked()) { $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); if ($affiliate->isPending()) { $mailer = new WPAM_Util_EmailHandler(); $mailer->mailAffiliate($affiliate->email, sprintf(__('Affiliate Application for %s', 'affiliates-manager'), $blogname), WPAM_MessageHelper::GetMessage('affiliate_application_declined_email')); } $affiliate->decline(); $db->getAffiliateRepository()->update($affiliate); return new JsonResponse(JsonResponse::STATUS_OK); } else { throw new Exception(__('Invalid state transition.', 'affiliates-manager')); } }
public static function __StaticConstructor() { if (self::$db === NULL) { self::$db = new WPAM_Data_DataAccess(); } }
<?php echo WPAM_MessageHelper::GetMessage('affiliate_application_declined');
<div class="wrap"> <h2><?php _e('Affiliate Control Panel', 'affiliates-manager'); ?> </h2> <h3><?php _e('Welcome!', 'affiliates-manager'); ?> </h3> <?php echo WPAM_MessageHelper::GetMessage('affiliate_application_approved'); ?> <br/><br/><br/> <a class="button-primary" href="<?php echo $this->viewData['confirmUrl']; ?> "><?php _e('Review Terms and Get Started!', 'affiliates-manager'); ?> </a> </div>
<?php echo WPAM_MessageHelper::GetMessage('aff_app_submitted_auto_approved');
<?php echo WPAM_MessageHelper::GetMessage('affiliate_application_pending');
<?php echo WPAM_MessageHelper::GetMessage('affiliate_application_submitted');